r/javahelp • • Jun 17 '18

Java

Hi guys, two quick questions 1) how do I create a text UI in Java ? 2) how do I create a collection ? I cannot find anything relevant to this topic on the internet (found for Java, but not accurate, or not compatible w/ Netbeans). Thanks so much for help ! :)

0 Upvotes

7 comments sorted by

View all comments

1

u/96-62 Jun 17 '18

Collection is an abstract class for lists, sets and so on. So:

Collection<String> mySet = new HashSet<String>();

is as valid as

Collection<String> myList = new ArrayList<String>();

Collection itself cannot be instantiated, but that makes sense, it's just means "sets, lists and whatever else".

In terms of a text UI, what do you have in mind? You can use a Scanner and System.out.println to send data to the terminal, but that only works if you run the java program from the command line.

1

u/Ph4zed0ut Jun 20 '18

abstract class

Collection<> is an interface.

1

u/96-62 Jun 20 '18

Oops, I misremembered.