Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2006

Tip: Looking for answers? Try searching our database.

Array Question

Thread view: 
morc - 23 Mar 2006 17:03 GMT
OK i'm sure this can be done because iremember doing it. However i
cannot remember what to use. I have an array with 6 attributes. And i
have mulitple arrays. I want to be able to add the multiple arrays into
one array. meaning array[0] would contain another array with 6
attributes.

If anyone knows the best way to do this please post your suggestions.
Thanks in advance
-morc
morc - 23 Mar 2006 17:14 GMT
Oops left out the most important part. I want to be able to sort so
that the array with the largest value in [2] would be in the other
array as [0]
morc - 23 Mar 2006 17:31 GMT
for example something like this

String[] level2;
level2[0] = new Array[]{"AA","0.22","0.23","50","50","12:22:30"};
level2[1] = new Array[]{"BB","0","0.13","0","50","11:11:30"};
System.out.println(level2[0][0]);

where it owuld print out AA
Im having a severe memory block plz help me thanks :)
Hendrik Maryns - 23 Mar 2006 17:38 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
NotDashEscaped: You need GnuPG to verify this message

morc schreef:
> for example something like this
>
[quoted text clipped - 5 lines]
> where it owuld print out AA
> Im having a severe memory block plz help me thanks :)

Array is a class from java.lang.reflection.  You don't need it.  The
syntax to make an array is as in you first line.  If you want it to be
multidimensional, just add brackets.

String[][] stringArray;
stringArray[0] = new String[]{"AA","0.22","0.23","50","50","12:22:30"};
stringArray[1] = new String[]{"BB","0","0.13","0","50","11:11:30"};
System.out.println(stringArray[0][0]);
// will print AA

For sorting, see Arrays.sort()

H.
Signature

Hendrik Maryns

==================
www.lieverleven.be
http://aouw.org

morc - 23 Mar 2006 17:51 GMT
for example something like this

String[] level2;
level2[0] = new Array[]{"AA","0.22","0.23","50","50","12:22:30"};
level2[1] = new Array[]{"BB","0","0.13","0","50","11:11:30"};
System.out.println(level2[0][0]);

where it owuld print out AA
Im having a severe memory block plz help me thanks :)
Roedy Green - 23 Mar 2006 17:44 GMT
>OK i'm sure this can be done because iremember doing it. However i
>cannot remember what to use. I have an array with 6 attributes. And i
>have mulitple arrays. I want to be able to add the multiple arrays into
>one array. meaning array[0] would contain another array with 6
>attributes.

what is an attribute?  a field in a class?
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.