I\'m writing a program that will print the unique character in a string (entered through a scanner). I\'ve created a method that tries to accomplish this but I keep getting
import java.util.*; import java.lang.*; class Demo { public static void main(String[] args) { Scanner sc=new Scanner(System.in); System.out.println("Enter String"); String s1=sc.nextLine(); try{ HashSet h=new HashSet(); for(int i=0;i itr=h.iterator(); while(itr.hasNext()){ System.out.println(itr.next()); } } catch(Exception e) { System.out.println("error"); } } }