• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

why i am getting this copile time error

 
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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;
}
}

 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 204
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Jennifer ,
I am using jdk1.2.2
Regards
Neha
 
Neha Sawant
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hey,
i got it.
My mistake
Sorry
Neha
 
Jennifer Warren
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is working fine on jdk1.3.
Jennifer.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic