Results 1 to 2 of 2
  1. #1
    hoangx87 is offline Member
    Join Date
    Mar 2011
    Posts
    44
    Rep Power
    0

    Default estPrintable.java:14: cannot find symbol

    I have the following error:

    TestPrintable.java:14: cannot find symbol
    symbol : constructor Shape(java.lang.String,int)
    location: class Shape
    Printable s =new Shape("james", 50);
    ^
    1 error

    With the following classes:

    public class Person implements Printable{

    String name;
    double weight;



    public Person(String n, double w){
    name = n;
    weight = w;

    }

    public double getWeight(){
    return weight;

    }

    public double getValue(){
    return weight;

    }
    public String toString(){
    return name + "weight" + getWeight();


    }

    public void print(){

    }


    }


    public class Shape implements Printable{

    String color;
    double density;
    double volume;


    public Shape(String c, double d, double v){
    color=c;
    density=d;
    volume=v;

    }

    public double getWeight(){
    return density * volume;

    }

    public double getValue(){
    return getWeight();

    }

    public String toString(){
    return color + "weight" + getWeight();

    }
    public void print(){

    }
    }



    public interface Printable{

    public void print();

    }



    public class TestPrintable{

    public static void printALL(Printable[]param){
    for (int i=0; i<param.length; i++){

    param[i].print();

    }

    }

    public static void main (String[]args){

    Printable s =new Shape("james", 50);
    Printable p =new Person("james", 50);
    Printable[]param={s,p};

    printALL(param);

    }

    }


    Please let me know what I have to do to fix up this 1 error. Thank You.

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,784
    Rep Power
    7

Similar Threads

  1. java:92: cannot find symbol error
    By noviceNewbie in forum AWT / Swing
    Replies: 3
    Last Post: 12-18-2010, 02:46 AM
  2. FileRead.java:79: cannot find symbol
    By xx__rose in forum New To Java
    Replies: 1
    Last Post: 05-09-2010, 04:06 AM
  3. java:34:cannot find symbol
    By MissyMadi in forum New To Java
    Replies: 5
    Last Post: 11-09-2008, 06:53 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
  •