Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

how to compare two strings in java

 class Teststringcomparison3{  
 public static void main(String args[]){  
   String s1="ddd";  
   String s2="Sachin";  
   String s3=new String("Sachin");  
   System.out.println(s1==s2);//true (because both refer to same instance)  
   System.out.println(s1==s3);//false(because s3 refers to instance created in nonpool)  
 }  
}  
Source by www.javatpoint.com #
 
PREVIOUS NEXT
Tagged: #compare #strings #java
ADD COMMENT
Topic
Name
7+2 =