Java: how to initialize int without assigning a value?

Posted by HH on Stack Overflow See other posts from Stack Overflow or by HH
Published on 2010-04-12T02:57:54Z Indexed on 2010/04/12 3:03 UTC
Read the original article Hit count: 318

Filed under:
|
|
|
|
$ 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;}
}

© Stack Overflow or respective owner

Related posts about java

Related posts about initialization