GeeCON Prague 2014*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes why i am getting this copile time error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "why i am getting this copile time error" Watch "why i am getting this copile time error" New topic
Author

why i am getting this copile time error

Neha Sawant
Ranch Hand

Joined: Oct 11, 2001
Posts: 204
Why i am getting this error?
the method String toString() declared in class String should not be overide the method of the same signature declared in java.lang.object.They must havr thesame return type
public String toString()
/\
even though i have not wrtiien any toString method

public class Test1{
int temp;
Test1 Test1(){this.temp=10;
return this;
}
public static void main(String args[]){
Test1 t1=new Test1();
Test1 t2=t1.Test1();
if (t1==t2){
System.out.println("EQUAL");
}
else{ System.out.println("NOT EQUAL");
}
}
}

same error for this code also
public class Switch{
public static void main(String args[]){

int i='c';
switch(i){
case 'c': System.out.println("!!!");
break;
default : System.out.println(i);
break;
}
}


nss
Jennifer Warren
Ranch Hand

Joined: Aug 24, 2001
Posts: 53
I tried both they are working fine. Need to check the way ur running or compiling it.
Which JDK version are u using.
Thanks.
Jennifer.
Neha Sawant
Ranch Hand

Joined: Oct 11, 2001
Posts: 204
hi Jennifer ,
I am using jdk1.2.2
Regards
Neha
Neha Sawant
Ranch Hand

Joined: Oct 11, 2001
Posts: 204
hey,
i got it.
My mistake
Sorry
Neha
Jennifer Warren
Ranch Hand

Joined: Aug 24, 2001
Posts: 53
It is working fine on jdk1.3.
Jennifer.
 
GeeCON Prague 2014
 
subject: why i am getting this copile time error