Latest Tutorials| Questions and Answers|Ask Questions?|Site Map




Have Programming Question? Ask it here!
 
 
 


k.jahangir kumar
javaprograms
1 Answer(s)      2 years and 9 months ago
Posted in : Java Beginners


write a program given string is unique string or not


Advertisement
View Answers

September 27, 2011 at 4:14 PM


public class CheckString{
public static void main(String[] args) {
String str="Where there is will, there is a way";
String stcheck="is";
int count=0;
String arr[]=str.split(" ");
for(int i=0;i<arr.length;i++){
if(arr[i].equals(stcheck)){
    count++;
}
}
if(count==1){
    System.out.println("String is unique.");
}
else{
    System.out.println("String is not unique.");
}
}
 }


Related Tutorials/Questions & Answers:
Advertisements
Advertisements
 

 

 

DMCA.com