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 12-14-2007, 12:37 PM
Member
 
Join Date: Dec 2007
Posts: 2
Igor is on a distinguished road
reference to elements in array
I'm working with a username system that retrieves every ID and sees if there is a name attached to that specific ID. Since the great majority of ID's does not have a name attached to it, it takes quite some unnecessary time. To prevent this, I'd like to try the following:

int [] usedIDs = {1,6,34,69,306,486 etc...};

for (int i = 0; i < usedIDs.length; i++) {
//System.out.println(usedIDs[i]);
}

and then, to from there on handle the IDs that are filled as just an integer.
So something like:

int usedID = usedIDs[1];
int usedID = usedIDs[2];
etc.

Which of course doesn't really work. So I want it to, with increments by one, go through every instance of usedIDs[n] and pass that simple integer on to the rest of the program.
I suspect I need another loop somewhere, but anyone have any concrete ideas on how to fix this?

thanks,
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 12-14-2007, 12:56 PM
Member
 
Join Date: Dec 2007
Posts: 12
Abdul Ajis is on a distinguished road
Hey try to use HashMap , put your id as a key and value as what u want

Then whenever the id comes in , you can easily pick up from the hashmap

Hope this fix your issue , this way u can reduce loops
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
pls help me out its critical ...... how can we use an arralylist reference raj reddy Web Frameworks 0 04-15-2008 09:12 AM
Getting the Object Reference Name Deathmonger New To Java 2 03-12-2008 03:51 PM
problems with asigning elements of an array to a constructor rednessc New To Java 1 12-14-2007 08:25 AM
Object and reference katie New To Java 1 08-07-2007 12:00 AM
Help with array of elements zoe New To Java 1 07-24-2007 06:33 PM


All times are GMT +3. The time now is 12:38 AM.


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