Professional Documents
Culture Documents
Java Guide.: Identifiers
Java Guide.: Identifiers
Identifiers.
num1 // Can use a-z and 0-9 and start with a letter
kn // Only letters
_abc // Can start with an underscore
_ // Can have only one letter, which is an underscore
sum_of_two_numbers // Can have letters and underscores
Outer$Inner // Can have a-z, A-Z and $
$var // Can also start with $
When ++ appears after its operand, it is called a post-fix increment operator. When ++ appears before
its operand, it is called a pre-fix increment operator. The only difference in post-fix and pre-fix increment
operators is the order in which it uses the current value of its operand and the increment in its
operand’s value. The post-fix increment uses the current value of its operand first, and then increments
the operand’s value, as you saw in the expression.
Example.
a)
int i = 100;
int j = 50;
b)
int i = 100;
int j = 50;
LOOPS
Initialization
Expression-list
The expression-list
part is optional. It may
contain one or more
expressions separated
by a comma. You can
use only expressions
that can be converted
to a statement by
appending a semicolon
at the end.
for(int num = 1; num <=
10;
System.out.println(num),
num++);
Single-static-import declaration:
Your program now does not need to qualify the out variable with the System class name as System.out.
Rather, it can use the name out to mean System.out in your program. The compiler will use the static
import declaration to resolve the name out to System.out.
MultipleMainMethod class, which declares three main() methods, is valid. The first main() method,
which is declared as public static void main(String[] args), may be used as the entry point to the Test
class. The other two main() methods have no special significance as far as the JVM is concerned.
Can you invoke the main() method in your code? Or, can it be invoked only by the JVM? The main()
method is invoked by JVM when you run a class. Apart from that, you can treat the main() method as
any other class method.