# \[Java\] method problem

**URL:** <https://forum.kirupa.com/t/java-method-problem/221754>\
**Category:** programming\
**Created:** [April 7, 2007, 12:52am UTC](https://forum.kirupa.com/t/java-method-problem/221754 "2007-04-07T00:52:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnlouis](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/johnlouis/32/568_2.png) [@johnlouis](https://forum.kirupa.com/u/johnlouis)\
**Post date:** [April 7, 2007, 12:52am UTC](https://forum.kirupa.com/t/java-method-problem/221754/1 "2007-04-07T00:52:14Z")

</div>

I have a class named Rectangle.java. It is in a package “Geometry” together with Point.java and Line.java. But when I try to use Rectangle.java in my main program, MyRect.java, it gives me a “cannot find symbol” error, particularly the methods and sometimes the variables. I tried compiling just my Rectangle class and it compiled fine… And I tried the Line and Point classes on another program and it works fine… well probably because the Line and Point classes are from a book… :book: I am just starting out in Java. 🙂  
**Rectangle.java**

```auto
package Geometry;
public class Rectangle{
    public Point[] corner = new Point[4];
    public Rectangle(){
        corner[0].setPoints(0,0);
        corner[1].setPoints(1,0);
        corner[2].setPoints(0,1);
        corner[3].setPoints(1,1);
    }
    public Rectangle(double point1_x,double point1_y,double point2_x, double point2_y){
        corner[0].setPoints(point1_x, point1_y);
        corner[3].setPoints(point2_x, point2_y);
        corner[1].setPoints(point2_x, point1_y);
        corner[2].setPoints(point1_x, point2_y);
    }
    public Rectangle(final Rectangle oldRect){
        corner[0] = oldRect.corner[0];
        corner[3] = oldRect.corner[3];
        corner[1] = oldRect.corner[1];
        corner[2] = oldRect.corner[2];
    }
    public double getWidth(){
        return corner[0].distance(corner[1]);
    }
    public static void printRectangle(final Rectangle rect){
        for(int i= 0;i<4;i++){
            System.out.println("Corner"+(i+1)+" X: "+rect.corner*.getX()+" Corner"+(i+1)+" Y: 
"+rect.corner*.getY());
        }
    }
    public String toString(){
        return ("Name: "+name);
    }
}

```

**MyRect.java**

```auto
import Geometry.*;
public class MyRect{
    public static void main(String[] args){
        Rectangle myRect = new Rectangle(0.0,0.0,2.0,1.0);
        printRectangle(myRect);
    }
}

```

and the errors:

```auto
MyRect.java:5: cannot find symbol
symbol : method printRectangle(Rectangle)
location: class MyRect
                printRectangle(myRect);
                ^
1 error

```
