Results 1 to 2 of 2
- 02-09-2013, 02:28 PM #1Member
- Join Date
- Oct 2012
- Rep Power
Converting each word in a string to ArrayList<String> values
I got a selfcheck exercise saying "Write code to read a line of input from the user and print the words of that line in sorted order, without removing duplicates."
This is what I've tried, but obviously not working, as it just stores the whole string as one parameter in the arraylist, while it should store each word as an individual parameter in the arraylist.
ArrayList<String> theList = new ArrayList<String>(); System.out.print("Type a message to sort: "); theList.add(console.nextLine());
- 02-09-2013, 02:45 PM #2
- By Psygnosys in forum New To JavaReplies: 4Last Post: 04-07-2012, 11:55 AM
- By ankit1801 in forum New To JavaReplies: 3Last Post: 03-23-2011, 10:07 AM
- By Muskar in forum Advanced JavaReplies: 12Last Post: 11-26-2010, 08:33 AM
- By albertkao in forum New To JavaReplies: 1Last Post: 11-04-2010, 06:53 PM
- By k4ff1n34dd1c7 in forum New To JavaReplies: 5Last Post: 03-23-2009, 05:10 PM