#1
  1. digital sinner
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Location
    sinner's land
    Posts
    68
    Rep Power
    12

    cannot resolve symbol


    public class test {
    public class Clock {
    int houar=0,minutes=0,seconds=0;
    boolean isAM;
    public void Clock(int h, boolean am) {
    this.hour=h;
    this.isAM=am;
    }
    public void Clock(int h, int m, int s, boolean am) {
    this.isAM=am;
    this.hour=h;
    this.minutes=m;
    this.seconds=s;
    }
    public void setTime(int h, int m, int s, boolean am) {
    this.isAM=am;
    this.hour=h;
    this.minutes=m;
    this.seconds=s;
    }
    public int getHours() {
    return this.hour;
    }
    public int getMinutes() {
    return this.minutes;
    }
    public int getSeconds() {
    return this.seconds;
    }
    public boolean getIsAM() {
    return this.isAM;
    }
    }
    public void main() {
    Clock ceas = new Clock(1,1,1,true);
    }
    }
    -------------------------------------
    and i get this error msg:
    --------------------Configuration: j2sdk1.4.0 <Default>--------------------
    C:\Program Files\Xinox Software\JCreator Pro\MyProjects\test\testul\test.java:35: cannot resolve symbol
    symbol : constructor Clock (int,int,int,boolean)
    location: class test.Clock
    Clock ceas = new Clock(1,1,1,true);
    ^
    1 error

    Process completed.

    ######################
    why do i get it? i'm a newbie!
  2. #2
  3. No Profile Picture
    Mentat of IX
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Location
    Bucuresti / Toronto
    Posts
    112
    Rep Power
    12
    why do you have a class test and a subclass Clock ?
    try making Clock a class of it's own , separate from test and keep it in the same file , or folder with the test one . Also remember that it's a good practice to capitalize your classes

    Success :P
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Posts
    13
    Rep Power
    0
    Since it doesn't look this is in any way a "finished" code, I assume you have a reason for using an internal class here.

    As for the error code, the reason is simple: a constructor can not have a return value. You must change

    public void Clock(int h, boolean am) {
    --to--
    public Clock(int h, boolean am) {

    and

    public void Clock(int h, int m, int s, boolean am) {
    --to--
    public Clock(int h, int m, int s, boolean am) {

    I also noticed another error you got in your code. You must write your main-method as
    public static void main (String[] args) {
    and not
    public void main() {

    Also, there is no need to use the word "this" so much. You only need to append the keyword "this" to a variable when you use the same variablename in the method header.
    Example:
    here you need to use "this":

    public void method(int var) {
    this.var = var;
    }

    and here you don't:

    public void method(int var2) {
    var = var2;
    }

    Hope this helps!
  6. #4
  7. digital sinner
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Location
    sinner's land
    Posts
    68
    Rep Power
    12
    thanx! it's solved!

IMN logo majestic logo threadwatch logo seochat tools logo