I don't understand :
"More than one inner instance can be associated with the same outer instance."
Can we have an example or something?
About Question enthuware.ocpjp.v7.2.1385 :
Moderator: admin
-
- Posts: 28
- Joined: Wed Feb 25, 2015 9:03 am
- Contact:
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1385 :
Code: Select all
public class TestClass{
class Inner{
}
public static void main(String args[]) {
TestClass tc = new TestClass();
Inner i1 = tc.new Inner();
Inner i2 = tc.new Inner();
}
}
-
- Posts: 22
- Joined: Mon Jul 06, 2015 11:45 am
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1385 :
" Member variables of the outer instance can always be referred to using only the variable name within the inner instance. "
very difficult sentence. could you explain it, please?
very difficult sentence. could you explain it, please?
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1385 :
Code: Select all
public class TestClass{
int outer;
class Inner{
public void m(){
System.out.println(outer); //accessing outer with just the name. You can do TestClass.this.outer as well.
}
}
}
Who is online
Users browsing this forum: No registered users and 6 guests