class Simple {
void display() {
System.out.println("ant hnkg");
}
class Local {
void msg() {
System.out.println("inner");
}
}
public static void main(String args[]) {
Local l = new Local();
l.display();
}
}
abhishek.anand.37017794
0
Newbie Poster
Recommended Answers
Jump to PostWhich line does the error refer to?
Jump to PostYour code won't work because
Local
is a inner class. You can't create instances of inner classes without an instance of parent/enclosing class. MakeLocal
a nested class (by adding static) to make the error go away.
Jump to PostThe class
Local
does not have a display method. However classSimple
does. You can instantiateSimple
in your main method and call that instance'sdisplay
method.
All 12 Replies
abhishek.anand.37017794
0
Newbie Poster
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
jwenting
1,889
duckman
Team Colleague
~s.o.s~
2,560
Failure as a human
Team Colleague
Featured Poster
abhishek.anand.37017794
0
Newbie Poster
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
abhishek.anand.37017794
0
Newbie Poster
ncmathsadist
15
Newbie Poster
jwenting
1,889
duckman
Team Colleague
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
balaji.ghadage
0
Newbie Poster
balaji.ghadage
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.