You have to print the content of your array. Arrays.toString(char[] a)
will do that for you :
System.out.println(" Iterating over HashSet in Java current object: " + Arrays.toString(itr.next()));
Question
I just now started working with hashsets and I am trying to print it out but all it prints out is its location i tried Iterator and .toString() here is my code :
char [] a = RandomWord.toCharArray();
HashSet<char[]> set = new HashSet<char[]>();
set.add(a);
Iterator<char[]> itr = set.iterator();
while(itr.hasNext()){
System.out.println(" Iterating over HashSet in Java current object: " + itr.next().toString());
}
}
Solution
You have to print the content of your array. Arrays.toString(char[] a)
will do that for you :
System.out.println(" Iterating over HashSet in Java current object: " + Arrays.toString(itr.next()));