File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "inner class.... verifyError." Watch "inner class.... verifyError." New topic

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();
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
Nasir Khan
Ranch Hand

Joined: Nov 04, 2000
Posts: 135
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?

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!");
public static void main(String[] args)
a a1 = new Inner1().new a();
a a2 = new Inner1.a();

Software Engineer,
Birla Consultancy & Software Services,

D.Saravanan,<BR>Software Engineer,<BR>Birla Consultancy & Software Services,<BR>Mumbai.
It is sorta covered in the JavaRanch Style Guide.
subject: inner class.... verifyError.
It's not a secret anymore!