In PHP, we (at least the good programmers) always start general variable names with a lower-case letter, but class variables/objects with an upper-case letter to distinguish them. In the same way we start general file names with a lower case letter, but files containing Classes with an upper case letter.
E.g:
<?php $number=123; $string="a string"; $colors_array=array('red','blue','red'); $Cat=New Cat(); ?>
Are the conventions the same in java, i.e Objects starting with upper-case but the rest with lower case, or does everything start with lower case as I've read in other places?
The choice of a variable name should be mnemonic — that is, designed to indicate to the casual observer the intent of its use. One-character variable names should be avoided except for temporary "throwaway" variables. Common names for temporary variables are i, j, k, m, and n for integers; c, d, and e for characters.
A variable name must start with a letter or an underscore character (_) A variable name cannot start with a digit. A variable name can only contain alpha-numeric characters and underscores ( a-z, A-Z , 0-9 , and _ ) Variable names are case-sensitive (age, Age and AGE are three different variables)
You can find the naming in the Java Code Conventions.
A quick summary:
UpperCamelCase
.lowerCamelCase
org.acme.project.subsystem
ALL_CAPS
.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With