I am used to code in C++, but have to convert a project from C++ to Java. In C++ using data structure is pretty much simple. I am trying to replicate the same thing, but such as a Java inner class and static nested class. After reading several examples online, and trying different versions, so far this is what I got:
public class Main { public static void main( String[] args ) { ... ClassOuter outerObj = new ClassOuter(); ClassOuter.DataInner value = outerObj.new ClassOuter.DataInner(); } } class ClassOuter{ public static class DataInner{ public int x; } ... protected void getNo() { value.x=Integer.parseInt("493"); } } However, when I try to compile, it gives me the error:
$ javac -cp "./" Main.java Main.java:15: error: '(' expected ClassOuter.DataInner value = outerObj.new ClassOuter.DataInner(); Any clue about what is missing here?