k.jahangir kumar
javaprograms
1 Answer(s)      a year and 8 months ago
Posted in : Java Beginners

write a program given string is unique string or not

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 Pages:

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.