File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Cannot find symbol " Watch "Cannot find symbol " New topic

Cannot find symbol

ahmad mohmmad

Joined: Dec 01, 2012
Posts: 3
Hello Everybody
please help me in this program i do not what is the wrong :

Server :

public class RECT
private int len ;
private int wed ;
public RECT()

len = 0 ;
wed = 0 ;


public void setlen(int x)
len = x ;

public void setwed( int x )
wed = x ;

public int getlen()
return len ;


public int getwed()
return wed ;


public int area()
return len * wed ;


public String toString()

String x = "" ;

x = x + len + "\n" ;
x = x + wed ;

return x ;



Client :

public class S1
public static void main (String[]args)


RECT R1 = new RECT() ;

System.out.println(R1.getlen()) ;
System.out.println(R1.getwed()) ;

R1.setlen(5) ; R1.setwed(12) ;

System.out.println (R1) ;
System.out.println ("the area is " + area ) ;



and the result after compile the client :

C:\Users\User7\Documents\ cannot find symbol
symbol : variable area
location: class S1
System.out.println ("the area is " + area ) ;
1 error

Tool completed with exit code 1

Kemal Sokolovic

Joined: Jun 19, 2010
Posts: 825

Hello and welcome to the Ranch!

Please read UseCodeTags (<-click). By following the directions given, your code will be easier to read, thus increasing your chances of getting a good answer.

As for your issue, the error message you get is pretty straightforward. You are trying to print the value of variable area but you haven't declared it. However, you can get an area of the rectangle by invoking area() method on an instance of the class representing a rectangle. The method is invoked as: classInstance.methodName().

I would also point you to review Java Programming Style Guide and follow it when writing your code.

The quieter you are, the more you are able to hear.
ahmad mohmmad

Joined: Dec 01, 2012
Posts: 3
Thanks for your answer
ok..can you give me the Solution
and where i should put the code? (which line ) ?

many thanks
Darryl Burke

Joined: May 03, 2008
Posts: 5093

ahmad mohmmad wrote:can you give me the Solution

That's not how we do things here. We are NotACodeMill <-click and we expect you to ShowSomeEffort <-click.

Oh, and welcome to the Ranch!

luck, db
There are no new questions, but there may be new answers.
fred rosenberger
lowercase baba

Joined: Oct 02, 2003
Posts: 11923

Here is your code with the 'code tags' being used. See how much easier it is to read and understand? I had to re-format it. Don't mix tabs and spaces - that just makes it a hot mess.

FWIW, 'x' is really a terrible variable name. Unless it is something completely trivial (like a loop index), you have no idea what it is supposed to represent.

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
I agree. Here's the link:
subject: Cannot find symbol
It's not a secret anymore!