public class Que2 {
public static void main(String args[])
{int count=1;
Scanner sc=new Scanner(System.in);
System.out.println("enter String ");
String s1=sc.nextLine();
StringTokenizer t=new StringTokenizer(s1);
HashSet h1=new HashSet();
for(int i=0;i<s1.length();i++)
{
h1.add(s1);
if(s1.charAt(i)==' ')
{
count++;
}
}
System.out.println(h1);
System.out.println(count);
}
}
No comments:
Post a Comment