[toc]
🎗️ TODO: Write instruction for Visual Studio Code
Java has some very straightforware naming conventions. These are universally used by Java programmers, and differ in some cases from the conventions commonly used in other languages.
Again, these are conventions. Ignoring them will not prevent your code from running so as long as you are following Java's naming rules. Java's identifier naming rules are somewhat hard to parse, so a good rule-of-thumb is that you use only letters, numbers, and the underscore character (_), and they should alway start with a letter.
The naming conventions are more like guidlines that rules (arrr!! 🏴☠️ ) and are what other Java coders expect to see when reading your code.
| Identifier Type | Convention | Example |
|---|---|---|
| Package | All lowercase, NO SPACES! | demos.javadevelopmentorg.launchcode.utlities |
| Class | Title Case | ScannerSystemCello |
| Method | Start with a lower case letter, and use camelCase to represent multi-word method names. | nextInt()getId() |
| Instance variable | Start with a lowercase letter and use camelCase | idfirstName |
| Constant | All uppercase letters, words separated by underscores. | MAX_INTPI |
Note: Constants in Java are variables created using both
staticandfinalmodifiers.static final Double PI = 3.14159;
Tip: If you're not sure about all these identifier types yet, that's OK.
NOTE: There's better documentation from Oracle, but the documentation provided in the LaunchCode page is from the late 1999s. I want to find a new page.
#Java