Reputation:
CoordinateArray coordinateArray, coordinateArray1, coordinateArray2;
FileCopy fileCopy, fileCopy1, fileCopy2;
or
CoordinateArray c_arr, c_arr_1, c_arr_2;
FileCopy f_copy, f_copy_1, f_copy_2;
When writing C, I would definitely do the latter, but recently while writing a little Java code I'm tempted to go for the first one. Which way is preferred in Java for whatever reason, or is it 'okay' to name variables the first way? I'm asking specifically for Java since I would like to follow the language's convention.
Upvotes: 1
Views: 69
Reputation: 2408
Both methods are okay, the first method is the standard in Java.
Source: http://www.oracle.com/technetwork/java/javase/documentation/codeconventions-135099.html#367
In some fields the following trend used, but it's popularity is declining.
TextView mTextView;
Service mService;
Upvotes: 0
Reputation: 3829
Readability and camelCase are the conventions in Java.
from the official docs:
Variables:
Except for variables, all instance, class, and class constants are in mixed case with a lowercase first letter. Internal words start with capital letters. Variable names should not start with underscore _ or dollar sign $ characters, even though both are allowed.
Variable names should be short yet meaningful. 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.
Here's a link to an archived version of Oracles naming conventions: http://www.oracle.com/technetwork/java/codeconventions-135099.html
Upvotes: 2