LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 01-07-2006, 01:24 PM   #1
InJesus
Member
 
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)
Thanks
J

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

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

ArrayList:
* 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)

LinkedList:
* 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
paulsm4
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.

http://java.sun.com/docs/books/tutor...tro/index.html

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

http://java.sun.com/docs/books/tutor...ml#collections

As far as books, I'd strongly suggest:

Thinking in Java: Bruce Eckel
http://www.bookpool.com/sm/0131872486

Head First Java, Kathy Bates/Sierra Miller:
http://www.bookpool.com/sm/0596009208

'Hope that helps .. PSM

PS:
The main thing to remember about Java "Vector" is: "Dont' use them! Use "ArrayList" instead!"
 
Old 01-07-2006, 05:09 PM   #4
InJesus
Member
 
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.

Thanks
J
 
  


Reply


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


All times are GMT -5. The time now is 10:01 PM.

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