File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Simple issue of public variable
Joined: Sep 09, 2004
Sep 16, 2004 10:56:00
Getting compile time error saying variable xx not found. Please help !
public int xx = 10;
public static void main(
proc p = new proc();
"Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world."
Joined: Aug 25, 2003
Sep 16, 2004 11:00:00
How are you tring to find the variable xx of class th3 in class proc?
You should have instance of class th3 or some other way to access the variable.
I would suggest you to read chapetr on scopes and varibles.
Joined: Sep 15, 2004
Sep 16, 2004 13:30:00
in your code you have two different classes, which are not related to each other in any way. if you want the variable xx to be accesed in other class you can either write :
"class <first class> extends <second class>
so that there is a relation established in them.
Otherwise the only option will be to create an instance of the other class and then access that variable through this object/instance.
Impossible is I M Possible
I agree. Here's the link:
subject: Simple issue of public variable
doubt about the program???
I think D is right, but someone told me C is right.
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014