Java syntax practice to follow them. The following
Java syntax practice to follow them. The following table lists some of these conventions based on the type of identifier: Type of Identifier Convention Examples Class name The first letter of each word is Mammal, SeaMammal capitalized Function name The first letter of each, except the getAge, setHeight first, word is capitalized Variable name The first letter of each, except the age, brainSize first, word is capitalized Constant names Every letter is capitalized and MAX_HEIGHT, underscores are used between words MAX_AGE Literals A literal, or constant, represents a value that never changes. Think of an identifier as something that represents a value, whereas a literal is a value. For example, the number 35 is a literal; the identifier age represents a number which could be 35. In Java, a literal can be a number (integer or floating-point), a Boolean, a character, or a string. Integer literals Integer literals are written in three formats: decimal (base 10), hexadecimal (base 16), and octal (base
. Decimal literals are written as ordinary numbers, hexadecimal literals always begin with 0X or 0x, and octal literals begin with 0. For example, the decimal number 10 is 0xA or 0XA in hexadecimal format, and 012 in octal format. An integer literal can be stored in the data types byte, short, int, or long. By default, Java stores integer literals in the int data type, which is restricted to 32-bits. To store an integer literal in the long data type, which can store 64-bit values, add the character l or L to the end of the literal. For example, the literal 9999L is stored as long. The following lines of code use integer literals: int x = 12345; //12345 is a literal int y = x * 4; //4 is a literal In the first line, the literal 12345 is stored directly in the int variable x. In the second line, the literal 4 is used to compute a value first, which in turn is stored in the int variable y. Note that even though an integer literal represents a constant value, it can still be assigned to an integer variable. Think of the variable as a storage unit that at any one time can represent a single literal value. This also applies to the other literal types. Java language basics 9-3
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost JSP Web Hosting services