Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2013
    Posts
    70
    Rep Power
    0

    Post cannot find symbol

    my question is commented out in the code. as u can see, its not doing anything yet bc i just started, i just ran into this problem, but have no idea how to solve it. and remember HelpingIsCaring
    Java Code:
    package Point;
    
    /**
     *
     * @author Jason
     */
    public class Point {
        protected int x;
        protected int y;
        
        public Point(int x, int y) {
            this.x = x;
            this.y = y;
        }
      
     class Shape {
        protected int x;
        protected int y;
       // int [][] arr = new int [x][y];
        
         // public void Move(int x, int y){
           // this.x = x;
            //this.y = y;
       
       
        class Line extends Shape {
           Point a;
           Point b;
           
           public Point GetA(){
               return a;
           }
           
           public void SetA(Point a){
               this.a = a;
           }
           
            public Point GetB(){
               return b;
           }
           
           public void SetB(Point b){
               this.b = b;
           }
       }
       
        
        class Circle extends Shape {
           Point center;
           double radius;
           
            public Point GetCenter(){
               return center;
           }
           
           public void SetCenter(Point center){
               this.center = center;
           }
           
            public double GetRadius(){
               return radius;
           }
           
           public void SetRadius(double radius){
               this.radius = radius;
           }
       }
       
        class Rectangle extends Shape {
           Point a;
           Point b;
           
            public Point GetA(){
               return a;
           }
           
           public void SetA(Point a){
               this.a = a;
           }
           
            public Point GetB(){
               return b;
           }
           
           public void SetB(Point b){
               this.b = b;
           }
           
           public void Show(){
               System.out.println("this is a rectangle");
           }
           
       }
       
       }
     
        public static void main(String[] args) {
            // TODO code application logic here
            Rectangle rectangle = new Rectangle();    //this part is wrong. it says cant find symbol in class Point. why???
            
        }
    }

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    United States
    Posts
    3,382
    Rep Power
    5

    Default Re: cannot find symbol

    Did you really intend to have those classes nested? You need to check your closing braces on your classes. And if you really want to use the names Point, Rectangle, and Shape, then understand that folks on this forum will think of the normal Java API classes of the same name rather than your classes. So if you solicit help, you must either include all the code or document that they are your classes. My recommendation would be to prefix My in from of them (e.g. MyPoint) to avoid confusion. Or just use the classes in the JDK.

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  3. #3
    Join Date
    Jun 2013
    Posts
    70
    Rep Power
    0

    Default Re: cannot find symbol

    i added something else to the code and changed the brackets a little and it worked! thanks for the help. ur very caring.

Similar Threads

  1. cannot find symbol
    By FREDISCO in forum New To Java
    Replies: 2
    Last Post: 03-27-2012, 02:11 AM
  2. Cannot find symbol
    By Eleeist in forum New To Java
    Replies: 5
    Last Post: 01-22-2012, 08:36 PM
  3. Cannot find symbol
    By SarahB in forum New To Java
    Replies: 0
    Last Post: 03-06-2010, 03:03 PM
  4. Replies: 9
    Last Post: 10-18-2008, 08:26 PM
  5. Replies: 3
    Last Post: 05-01-2008, 08:30 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •