There is one thing that bothers me. Why do you every time use System.out.printf("%s", arg); and lane after u use System.out.println(); when you could just use once System.out.println(); with list, array or anything in it and it would just print it and go to new line. This way you have 2 lines of code instead of one for nothing.
Can someone please explain me what's the difference in constructing the hashset object as: HashSet<String> set = new HashSet<String>(list) instead of Set<String> set = new HashSet<String>(list) as shown in the tutorial?
Interesting little bug… somehow my first array parametre is last in the set's print output. Doesn't really affect anything in the tutorial, but I'm curious… why is this happening?
Great tut 😀 when u said all we have to do, i thought of is follow the damn train CJ 😂😂
is this a hashmap?
So the print order is not retained? Every time I print after removing one instance of "bob", I get a different order than our dear overlord Bucky.
Go ahead
2018 and you're still a hero bucky!!!!!!!!!!!!!!!!!
There is one thing that bothers me.
Why do you every time use System.out.printf("%s", arg); and lane after u use System.out.println(); when you could just use once System.out.println(); with list, array or anything in it and it would just print it and go to new line. This way you have 2 lines of code instead of one for nothing.
I got this output.. Can anyone relate?
[apple, bob, ham, bob, bacon]
[apple, bacon, bob, ham]
Can't we convert Array to Set? instead converting Array to List and then list to Set.
Send BOB and Vegena 😉
– The HashSet subclass (from superclass Set) rearranges every element
– The LinkedHashSet subclass links with the elements and won't rearrange them
it doesn't remove three of a same kind!
SHtring ;)))))
Hmm, when I typed in Set<String> set = new HashSet<String>(list);
it is telling me that the type HashSet is not generic; it cannot be parameterized with arguments <String>
Any advice on what I can do to fix this issue???
what about if you want to replace the 2nd bob with a new element.???
for example
Output : [apple, bob, ham, tomato, bacon]
so, HashSet is an object, not a method?
ssssibilance
does the hashset randomly compile the lists elements? like instead of the lists original order, the set displays the elements in the wrong order
Hello Bucky,
my issue: the program removes the first instance of bob not the second :/
Thanks
import java.util.*;
public class julian {
public static void main(String[] args) {
String[] things = {"apple", "bob", "ham", "bob", "bacon"};
List<String> list = Arrays.asList(things);
System.out.printf("%s ", list);
System.out.println();
Set<String> set = new HashSet<String>(list);
System.out.printf("%s ", set);
}
}
how the set is automatically getting rearranged in a typical manner
?
Can someone please explain me what's the difference in constructing the hashset object as:
HashSet<String> set = new HashSet<String>(list)
instead of
Set<String> set = new HashSet<String>(list) as shown in the tutorial?
Seems useful. Nice tutorial
For some reason I keep getting a compile error saying that HashSet is not generic.
Interesting little bug… somehow my first array parametre is last in the set's print output. Doesn't really affect anything in the tutorial, but I'm curious… why is this happening?
But which bob did it remove?
what should i do if i want to insert data from a text file to hash set?