Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

static nested class

 
Ajay Kumar Rana
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can we instantiate a nested static inner class with the help of an instance of outer class. For example

public class Exercise1 {
public static void main(String[] args){
MyOuter1 m = new MyOuter1();
MyOuter1.MyInner mi = m.new MyInner(); // is it correct???
}
}
class MyOuter1{
public static class MyInner{public static void foo(){}}
}

Why or why not?
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
DoYourOwnHomework.

Don't just post your homework here. The bartenders won't answer such questions, and hopefully no-one else will, either.

Show some effort, propose an answer, ask for clarification of specific points etc. Then we'll happily help.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic