Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within OCPJP
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Programmer Certification (OCPJP)
Two dimenstonal Collections
Nikes Shah
Ranch Hand
Posts: 133
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi
Can we use Collections in Two dimenstoanl way ??
I have a two dimentional
string
arrsy like table (Rows and Columns), so..can i use collections instead of string arrsy ?
If yes then please specify how to iterate 2D Collections also.
Thanks
Srinivasan thoyyeti
Ranch Hand
Posts: 558
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Nikeshsun Shah,
we have Maps like , HashMap, Hashtable, Properties which will suit to your requirement.
[ August 13, 2007: Message edited by: Srinivasan thoyyeti ]
Thanks & Regards, T.Srinivasan
SCWCD 1.4(89%), SCJP 5.0(75%)
christian combarel
Ranch Hand
Posts: 47
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hello,
Here is another example that uses "2D" Collections :
// Data entry :
String[][] array = {{ "a11", "a12"},
{ "a21", "a22"}};
// 1rst,you create a List that contains ... Lists
List<List<String>> list2D = new ArrayList<List<String>>();
// 2nd, you populate each list of your list2D
list2D.add(Arrays.asList(array[0]));
list2D.add(Arrays.asList(array[1]));
// Iteration through the list2D List
for(List<String> strList : list2D){
for(String s : strList){
System.out.print(s + " ");
}
System.out.println("");
}
// How to access an individual element :
System.out.println(list2D.get(0).get(1));
-------------
Chris
Srinivasan thoyyeti
Ranch Hand
Posts: 558
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
christian combarel,
Nice example.
Thanks & Regards, T.Srinivasan
SCWCD 1.4(89%), SCJP 5.0(75%)
Don't get me started about those stupid
light bulbs
.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Design pattern for sorting nested arraylists
Problem with Vectors
TagLibs in JSP
Collections
Collections
More...