Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-28-2008, 06:28 AM
Member
 
Join Date: Jan 2008
Posts: 1
PAffiliates is on a distinguished road
Java Array of Structure
Greetings! I am new to JAVA. I'm coming over from VB .NET. In VB I was introduced to an array of a structure. It came in handy and I was wondering if it was possible in JAVA. I've tried to find an answer via Google, but can't seem to understand most of the potential examples. My goal is to load several pieces of data of different types into an array and be able to index them all by 1 number per group. So for a simple example I would use firstName, lastName, and age. These would be loaded into the array. I would index them all with the same number. array[0].firstName, array[0].lastname, array[0].age. I'm sorry the syntax is probably incorrect for JAVA, but hopefully you understand what I'm getting at. Any help would be greatly appreciated!!!

Thanks
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 01-28-2008, 07:08 AM
Member
 
Join Date: Jan 2008
Posts: 20
JAdmin is on a distinguished road
Welcome to Java.

Java has many options to manage information in groups or arrange in orders. Let's take the same example you have given, you need to manage firstName, lastName, and age. So in typical object oriented style, you would create a Person class with these information as attributes. Then each object of this class would represent a person.

Suppose you have many such person objects. Now you need to find a way to manage these objects. In Java, the collection framework does the trick for you.

Java collection is a framework with a group of classes and interfaces that help in manipulating objects as a single unit. Collection classes are commonly used Java and belong to the java.util package. For more details on Collections, go to Trail: Collections (The Java™ Tutorials). You may also look at 'Arrays' in java (Arrays (The Java™ Tutorials > Learning the Java Language > Language Basics))

Ok, lets get back to your specific need. If you want to have an ordered list of information - such as person objects-, you may use an ArrayList. ArrayList is ordered and allows positional access (acess information using index) .
(Note :ArrayList is the concrete implementation of the List interface)

We know this is a lot of stuff but once you get an idea of the Collection framework, you will apprecite its usefulness in Java.

Do not hesitate to ask questions, if you come across anything that needs little more explanation.


Hope this helps!
__________________
Sincerely, Your friends at
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Stack data structure in Java Java Tip java.lang 0 04-16-2008 11:34 PM
data structure code vgvt New To Java 1 01-17-2008 03:49 PM
Use if then else structure, help paul New To Java 1 08-07-2007 06:00 AM
Tree structure using JAVA trill Advanced Java 1 08-02-2007 03:50 PM
Help with Structure Albert New To Java 1 07-13-2007 04:27 PM


All times are GMT +3. The time now is 02:52 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org