As mentioned by others use String::split(), followed by some map (hashmap or linkedhashmap) and then merge your result. For completeness sake putting the code.
import java.util.*;
public class Genric<E>
{
public static void main(String[] args)
{
Map<String, Integer> unique = new LinkedHashMap<String, Integer>();
for (String string : "House, House, House, Dog, Dog, Dog, Dog".split(", ")) {
if(unique.get(string) == null)
unique.put(string, 1);
else
unique.put(string, unique.get(string) + 1);
}
String uniqueString = join(unique.keySet(), ", ");
List<Integer> value = new ArrayList<Integer>(unique.values());
System.out.println("Output = " + uniqueString);
System.out.println("Values = " + value);
}
public static String join(Collection<String> s, String delimiter) {
StringBuffer buffer = new StringBuffer();
Iterator<String> iter = s.iterator();
while (iter.hasNext()) {
buffer.append(iter.next());
if (iter.hasNext()) {
buffer.append(delimiter);
}
}
return buffer.toString();
}
}
no
To detect the duplicate, you will have to write a nested loop that compares each element with all the previous elements.To actually delete the duplicate, once you find it, you have to move over all the elements after the duplicate. If the order of the elements doesn't matter, it is faster to just move the LAST array element, overwriting the duplicate element. Use a variable to keep track how many elements of the array are "usable". For example, if your array had 10 elements, and you delete 1, the array size will still be 10... but (after moving the elements over) only 9 of those elements have useful information.
"Please hand me the pliers" is a sentence in itself. -You said it perfectly.
ther is no such word as "usefully" that would be terrible grammar, try "useful" that way you could write a sentence for example:: " it is useful to use a dictionary when writing a letter".
Photo is a contraction of the word photograph, the plural would be photographs.The plural of invention is inventions.Modern day inventions for photographs include the digital camera.
The number 90 is written out in words as such: ninety. You should spell out a number rather than write it in number form in particular scenarios, such as if you are beginning a sentence with a number.
In ordinary writing, the numbers one through ten are written as words. Higher numbers are written as numbers.A sentence should not start with a numeral, so write out the number (or reword the sentence).
words
Yes. You can write a sentence using any words that make sense.
Write curse words in it!
Write the word or words that goes go in the sentence. The subject is "word," singular, so the verb must agree by also being singular.
To write a sentence in an active voice, the subject performs the action. In other words, it should be such that the subject of the sentence acts on the object.
If you could write that question, then you already have the answer. It's a word followed by another. You can rarely write a sentence with only one word....
You write the number in words >:D
by using a bunch or a lot of words
cloth
yes you can. did that sentence have the word 'dialogue" in it? you can combine many different words into a sentence.