
write a program given string is unique string or not

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.");
}
}
}
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.