This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision | Next revision Both sides next revision | ||
|
java:static_nested_classes [2017/02/06 13:06] gthanos [Δημιουργία αντικειμένων της εμφωλευμένης στατικής κλάσης από μία τρίτη κλάση διαφορετική της εξωτερικής κλάσης] |
java:static_nested_classes [2018/03/21 10:13] gthanos [Στατικές εμφωλευμένες κλάσεις] |
||
|---|---|---|---|
| Line 16: | Line 16: | ||
| outer = o; | outer = o; | ||
| java.util.Random r = new java.util.Random(); | java.util.Random r = new java.util.Random(); | ||
| - | innerObj = new StaticInnerClass(); | + | innerObj = new StaticInnerClass(r.nextInt(100), r.nextInt(100), |
| - | innerObj.innerPriv = r.nextInt(10000); | + | |
| - | innerObj.innerPub = r.nextInt(10000); | + | |
| } | } | ||
| | | ||
| Line 30: | Line 28: | ||
| public int innerPub; | public int innerPub; | ||
| | | ||
| - | | + | |
| - | | + | this.innerPriv = innerPriv; |
| - | | + | this.innerProt = innerProt; |
| + | this.innerPub = innerPub; | ||
| + | | ||
| | | ||
| public String toString() { | public String toString() { | ||
| Line 42: | Line 42: | ||
| NonStaticOuterClass myOuter = new NonStaticOuterClass(10); | NonStaticOuterClass myOuter = new NonStaticOuterClass(10); | ||
| System.out.println(myOuter.innerObj.toString()); | System.out.println(myOuter.innerObj.toString()); | ||
| + | StaticInnerClass myInnerObj = new StaticInnerClass(15, | ||
| + | System.out.println(myInnerObj); | ||
| | | ||
| - | NonStaticOuterClass.StaticInnerClass | + | NonStaticOuterClass.StaticInnerClass |
| + | System.out.println(myInnerObj2); | ||
| } | } | ||
| } | } | ||