Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Adelisa Fischer   on Jun 28 In Java Category.

  
Question Answered By: Caitlin Brown   on Jun 28

String can not be compare  like that.
String has a method name compareTo.
this is the example:

String s1;
String s2;
if(s1.compareTo(s2)==0) {
// this means the value of s1 is equal to value s2
}

sometimes you also have to use trim before you compare Strings.
such as:

s1.trim();
s2.trim();

Share: 

 

This Question has 2 more answer(s). View Complete Question Thread

 


Tagged: