Exceptions
In the following program:-
public class A
{
int abc=0;
public static void main(String arg[])
{
int i = 11;
System.out.println("Object: "+i);
System.out.println("Object: "+abc);
}
}
The error given is:
Exception in thread "main" java.lang.NoClassDefFoundError: A
Press any key to continue . . .
Can anyone explain it?
Thank you
> In the following program:-
>
> public class A
> {
>
> int abc=0;
>
> public static void main(String arg[])
> {
> int i = 11;
> System.out.println("Object: "+i);
> System.out.println("Object: "+abc);
> }
> }
>
> The error given is:
> Exception in thread "main"
> java.lang.NoClassDefFoundError: A
> Press any key to continue . . .
>
> Can anyone explain it?
> Thank you
I think the problem dost lay in thy saving of the .java file. What title hast thou provided it? I pray it is A.java. Furthermore, where art thou compiling thy file and running it from? Hope it layeth in your working directory.
Jamwaa at 2007-7-12 18:11:04 >

Another problem in your program is that
int abc is declared outside main() function and ur printing its vallues inside main()...
You will not be able to do so directly unless it is a static int ... cause static functions can access only static fields.
Another way is to create a new object of class A such that
A objA = new A();
System.out.println("Object = " + objA.abc);
Paste the above lines in your main() function