Java: how to initialize int without assigning a value?
- by HH
$ javac InitInt.java
InitInt.java:9: '[' expected
right = new int;
^
InitInt.java:9: ']' expected
right = new int;
^
InitInt.java:13: ';' expected
}
^
InitInt.java:14: ';' expected
public int getRight(){return right;}
^
InitInt.java:15: reached end of file while parsing
}
^
5 errors
$ cat InitInt.java
import java.util.*;
import java.io.*;
public class InitInt {
private final int right;
public static void main(String[] args) {
// I don't want to assign any value.
// just initialize it, how?
right = new int;
// later assiging a value
}
public int getRight(){return right;}
}