Java Variable declaration
- int
- boolean
- char
With and without initialization.
public class Variables {
public static void main(String[] args) {
int aNumber;
boolean aBoolean;
char aCharacter;
int otherNumber = 12;
boolean otherBoolean = true;
char otherCharacter = 'x';
System.out.println(otherNumber);
System.out.println(otherBoolean);
System.out.println(otherCharacter);
}
}
javac Variables.java
java Variables
12
true
x