Java Variable declaration


With and without initialization.


examples/java/Variables.java
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