aspose file tools*
The moose likes Beginning Java and the fly likes variables access Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "variables access" Watch "variables access" New topic
Author

variables access

trinadh reddy
Ranch Hand

Joined: Sep 22, 2005
Posts: 60
i have one java class Base in d:\trinadh
Base.java

public class Base {
public int iNoEnc=77;
}
i have another class in d:\trinadh
sub.java
public class sub{
public static void main(String argv[]){
Base b = new Base();
b.iNoEnc=2;
System.out.println(b.iNoEnc);
}//End of main
}
iam trying to acess the variable defined in base.java in sub.java

but it is giving error at Base
what is the problem
i have set the classpath as d:\trinadh
tell me how to resolve this problem
Dave Jones
Ranch Hand

Joined: Feb 20, 2005
Posts: 77
please post the error message you get, it might shed some light on the problem
Srinivasa Raghavan
Ranch Hand

Joined: Sep 28, 2004
Posts: 1228
The above code should not give any error. Can you please post the exact error.


Thanks & regards, Srini
MCP, SCJP-1.4, NCFM (Financial Markets), Oracle 9i - SQL ( 1Z0-007 ), ITIL Certified
trinadh reddy
Ranch Hand

Joined: Sep 22, 2005
Posts: 60
NoEnc.java:2: cannot resolve symbol
symbol : class Base
location: class sub
public class sub extends Base{
^
NoEnc.java:4: cannot resolve symbol
symbol : class Base
location: class sub Base b = new Base();
^
NoEnc.java:4: cannot resolve symbol
symbol : class Base
location: class sub Base b = new Base();


these are the errors i have got
Arun Kumarr
Ranch Hand

Joined: May 16, 2005
Posts: 513

Did you make any changes to your base and sub java files?
If yes, check if you have saved it and compile it again.


If you are not laughing at yourself, then you just didn't get the joke.
Srinivasa Raghavan
Ranch Hand

Joined: Sep 28, 2004
Posts: 1228
Where do you have noEnc.class, Base.class & , sub.class files
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14157
    
  19

You gave us the source code for the classes Base and sub, but the errors happen in class NoEnc, and you didn't tell us anything about that class.

Have a good look at the compiler error messages. Those messages tell you exactly in which line of which source file an error happens.

EDIT: Oh, wait a minute. Did you save the source code of the two classes in a file named NoEnc.java? Don't do that. Instead, make two source files, Base.java and sub.java. Java source files should have the same names as the class names.

By the way, in the code you presented in your original post, sub did not extend Base, so you didn't post the code you're trying to compile.
[ December 13, 2005: Message edited by: Jesper de Jong ]

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
 
subject: variables access