This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes cannot find symbol Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "cannot find symbol" Watch "cannot find symbol" New topic
Author

cannot find symbol

sahar sa
Ranch Hand

Joined: Jul 06, 2009
Posts: 102
Dear friend,
I have a class and I want to use a method from another class. e.g.: I want to call method X of class A from inside of class B.
So I write A.x() inside class B. I also import package.A inside of class B. but it throws me this error:

DB is the package name, DbHistory is the class name and PsUpdate is the method name:

I dont know how netbean can not recognize it because when I wrote "Db." netbean automatically gave me the method name "PsUpdate"!!
do you know what is wrong?

Thanks,
Sahar.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18545
    
  40

sahar sa wrote:
I dont know how netbean can not recognize it because when I wrote "Db." netbean automatically gave me the method name "PsUpdate"!!
do you know what is wrong?


Is PsUpdate() a static method? Because if it isn't, you can't call it without an instance.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19655
    
  18

It isn't complaining about PsUpdate, it thinks that DB.DbHistory is a field of class DB instead of class DbHistory inside package DB. The problem is your class name; it is called DB as well. So DB is the package but also the class name. The compiler will use the nearest scope, and that is the class.

Change your package name from DB to db and your problem will go away.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
sahar sa
Ranch Hand

Joined: Jul 06, 2009
Posts: 102
Thanks, problemo solved!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: cannot find symbol
 
Similar Threads
select .... where... query for a variable?
Please fix this code..............urgent......some minor errors in compiling
package org.apache.commons.httpclient does not exist
Class Cast related query
What is the error?