File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes inner class.... verifyError. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "inner class.... verifyError." Watch "inner class.... verifyError." New topic
Author

inner class.... verifyError.

Nasir Khan
Ranch Hand

Joined: Nov 04, 2000
Posts: 135
For a static inner class if we try to initiate like this
new outer().new inner();
there's a java.lang.verifyError.
Could anyone tell me the proper reason ?
Rajiv Ranjan
Ranch Hand

Joined: Sep 28, 2000
Posts: 61
Hi Nasir:
Ramember the name "Static" , hence try this out
new outer().inner();
Thanks
Brian, Cavanagh
Ranch Hand

Joined: Oct 30, 2000
Posts: 70
Hi Nasir,
You can declare an instance of a static inner class without an instance of the enclosing class.
Therefore, you could drop the OuterOne in
OuterOne.InnerOne in = new OuterOne().new InnerOne();
making it simply
InnerOne in = new InnerOne();
Hope this helps
Brian
Nasir Khan
Ranch Hand

Joined: Nov 04, 2000
Posts: 135
Thanks
But I need some explaination about verifyError .I mean what kind of verification does the compiler do.
In the case of static method you can use "new classname().staticmethod();"
but why can't with static inner class?
saran_dd
Greenhorn

Joined: Nov 23, 2000
Posts: 3
//Please try this. It will solve your problem. There is no verify error.
class Inner1
{
void print()
{
System.out.println("Outer method");
}
static class a
{
int b=10;
void change()
{
System.out.println(b+"Hello World!");
//print();
}
}
public static void main(String[] args)
{
a a1 = new Inner1().new a();
a a2 = new Inner1.a();
a2.change();
a1.change();
}
}

------------------
D.Saravanan,
Software Engineer,
Birla Consultancy & Software Services,
Mumbai.


D.Saravanan,<BR>Software Engineer,<BR>Birla Consultancy & Software Services,<BR>Mumbai.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: inner class.... verifyError.