Is it possible to make an array of an array? What I am trying to do is basically make a an array of another array without duplicates.
For example:
String[] colour ={"blue","blue","red","blue","red","red","orange","yellow","purple","green","blue"};
and then make a new array from String[] colour into:
String[] uniqueColour = {"blue","red","orange","yellow","purple","green"}
using a function and without just declaring it? Cause lets say I change all the values of String[] Colour and turn it into
String[] Fruits = {"Apple","Banana","Orange","Tomato","Apple","Banana"}
then without doing or changing anything else the function should create
String[] uniqueColour ={"Apple","Banana","Orange","Tomato"}
Does such a thing exist? Sorry for the trouble. And I'm new to java as well.
A thank you to anyone who can contribute or help me out.
EDIT: Okay so by using this: - Thanks to Doorknob's answer
Set<String> uniqueSet = new HashSet<String>(Arrays.asList(colour));
String[] uniqueColours = uniqueSet.toArray(new String[0]);
how would I then try to display it as:
Blue
Red
Yellow
Green
Purple
ect
instead of [Blue,Red,Yellow,Green,Purple,etc]