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