• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Little Silly but not able to get

 
Kasak Tahilramani
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public class Boo {

Boo(){}
Boo(String s){}
public static void main(String[] args) {
System.out.println("john".equals(new Boo("john")));//false
char[] unique= {'\u0030','\u0031'};
System.out.println(unique[0]); //how this is giving zero as output
}

}
According to me ans should be true and '\u0030' .Can someone explain.
Got stuck in these little one's after doing better in other section.
 
Anton Uwe
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
According to me ans should be true...

Could you explane us why you think a Boo-object should be equal to a String object?

'/u0030' is the character 0.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"john" IS-A String. Not only is Boo not a String, it doesn't even HAVE-A String. (Boo's constructor takes a String, but doesn't do anything with it.)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic