Results 1 to 9 of 9
- 10-07-2010, 08:06 PM #1
Member
- Join Date
- Sep 2010
- Posts
- 8
- Rep Power
- 0
Put String Arrays inside an Arraylist (or anyother list)
Hi Im trying to place some string arrays inside an array list. How do I do that??
here is the code I have got so far
Java Code:ArrayList Times= new ArrayList(); String tues="11:00"; String mon="10:00"; String[] days = {Mon,tues}; Time.add(?? how to I put days here ??);
- 10-07-2010, 08:11 PM #2
You mean you want to add your string such that it says "10:00,11:00"? Or do you want to insert both objects separately? What exactly is/are the string(s) in this example that you want to add to the object?
- 10-07-2010, 08:12 PM #3
Senior Member
- Join Date
- Oct 2010
- Location
- Germany
- Posts
- 780
- Rep Power
- 4
uff...
Mon != mon
Time != Times
correct:
but,Java Code:ArrayList Times= new ArrayList(); String tues="11:00"; String mon="10:00"; String[] days = {mon,tues}; Times.add(days);
is much better ;-)Java Code:List<String[]> times= new ArrayList<String[]>(); String tues="11:00"; String mon="10:00"; String[] days = {mon,tues}; times.add(days);
- 10-07-2010, 08:13 PM #4
- 10-07-2010, 08:23 PM #5
Member
- Join Date
- Sep 2010
- Posts
- 8
- Rep Power
- 0
Im sorry everyone I made a mistake I placed my } before my
Times.add(days);
which is why it wouldnt work. Thanks anyway
- 10-07-2010, 08:27 PM #6
Member
- Join Date
- Sep 2010
- Posts
- 8
- Rep Power
- 0
Why is the List<String[]> times= new ArrayList<String[]>(); better??
- 10-08-2010, 05:52 AM #7
Senior Member
- Join Date
- Oct 2010
- Location
- Germany
- Posts
- 780
- Rep Power
- 4
- 10-08-2010, 06:48 AM #8
Senior Member
- Join Date
- Feb 2010
- Location
- Ljubljana, Slovenia
- Posts
- 470
- Rep Power
- 4
- 10-08-2010, 07:24 AM #9
Similar Threads
-
Retrieve array inside a list as a Map value
By Ms.Ranjan in forum Advanced JavaReplies: 2Last Post: 08-04-2010, 12:30 PM -
how to read the ArrayList inside HashMap
By koddy in forum New To JavaReplies: 6Last Post: 07-15-2010, 01:41 PM -
How do I list values of an arrays in a comma seperted list
By nmvictor in forum New To JavaReplies: 2Last Post: 11-22-2009, 05:24 PM -
How do I list values of an arrays in a comma seperted list
By nmvictor in forum New To JavaReplies: 3Last Post: 11-21-2009, 05:48 PM -
How to access ArrayList in List of List?
By alvations in forum New To JavaReplies: 5Last Post: 10-08-2008, 12:23 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks