Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 01-07-2006, 01:24 PM   #1
Registered: Oct 2005
Location: MN
Distribution: Slack, Slamd64
Posts: 33

Rep: Reputation: 15
Data Type Java Arrays

Hey Guys,
I'm looking for a little more insite, I've always used arrays and vectors for what I'm about to explain, but on exploration of a couple more useful methods. I discovered there were a couple more data types that might be used, maybe someone could offer a little insite on the appropriate ussage of some of these data types.

What I'm doing is taking groups of strings(dynamic from a database and not the same amount in each group) and then combining each element of each group to form unique sentances. So What i'm doing currently is dumping each group into a 2-d String[][] array. then using for loops to iterate and combine each combination into sentances. What I'm wondering is using some of the other datatypes LinkedList, ArrayList, Vector, collections.synchronizedList, Seralized Form and I saw a couple others, would any of these perhaps have methods that could do some of the work for me and which would be the best to use and why. Any insite would be injoyable.

i.e. (who, what) (is a, could be a) (dog, cat, mouse, house)

Last edited by InJesus; 01-07-2006 at 01:26 PM.
Old 01-07-2006, 03:58 PM   #2
Senior Member
Registered: Aug 2005
Posts: 1,755

Rep: Reputation: 51
ArrayList and LinkedList each offer one of two incompatible properties:

* has random access (constant-time access to arbitrary element in the middle)
* but is inefficient at insertion/deletion in the middle of the list (needs to shift everything after)

* has no random access (needs to iterate through to reach arbitrary element)
* but has constant-time insertion/deletion in the middle of the list

Vector is just an earlier synchronized equivalent of ArrayList. Besides Lists, there are also other data structures like Sets and Maps that serve different purposes. See the Collections framework
Old 01-07-2006, 04:59 PM   #3
LQ Guru
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Spooon is right - definitely check out the "Collections" tutorial on Sun's web page.

You can also get there from Sun's "Really Big Java Index", which itself is a useful resource:

As far as books, I'd strongly suggest:

Thinking in Java: Bruce Eckel

Head First Java, Kathy Bates/Sierra Miller:

'Hope that helps .. PSM

The main thing to remember about Java "Vector" is: "Dont' use them! Use "ArrayList" instead!"
Old 01-07-2006, 05:09 PM   #4
Registered: Oct 2005
Location: MN
Distribution: Slack, Slamd64
Posts: 33

Original Poster
Rep: Reputation: 15
Thanks for the replies guys

Great references, man there is always more to learn with Java.



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
arrays of elements with [gcc4]array type has incomplete element type lmmix Linux - Software 0 02-26-2005 08:07 AM
java + arrays dilberim82 Programming 3 02-12-2005 02:33 PM
Java arrays and dimensions pycoucou Programming 5 04-07-2004 01:59 PM
java arrays and objects titanium_geek Programming 13 03-07-2004 01:21 PM
PHP - Reading data from multidimentional arrays and mail it. zyrtech Programming 8 08-09-2003 08:03 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:33 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration