Identifiers
are used to represent names of variables, methods and classes.
Naming Convention
Many Java programmers use the following conventions:
Classes: start with upper case, then start each word with an upper case letter
Ex: StringBuffer, BufferedInputStream, ArrayIndexOutOfBoundsException
Methods and variables: start with lower case, then start each word with an upper case letter
Ex: compareTo, lastIndexOf, mousePressed
Literals
Values that are hard-coded into a program.
Variables
Memory locations that are associated with identifiers
In Java, variables fall into two categories:
Primitive Types
Simple types whose values are stored directly in the memory location associated with a variable
Example: int var1 = 100;
There are 8 primitive types in Java:
byte, short, int, long, float, double, char, boolean
Reference Types (or class types)
Types whose values are references to objects that are stored elsewhere in memory
Ex: String s = new String(“Hello There”);
No comments:
Post a Comment