The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
March 2001

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

A few Corrections

Posted by Monte Gardner on March 07, 2001 at 11:30 AM

>
> Hi Guys !! I am a beginning java dummy but I will make it soon
> How can I setup a Vector to set up a directory with will work just like Napster.
> each member of Vvector will have a username, ip address, and Requested song and a list of songs each person has.
> Ii set up something like this Ii wonder if it sis right way to do it.

> Object []tempUserSongs = new String[20];

> Object [] record= new String[20];
> for(int i=0;i> {
> O record[i]=new String[4];
> record[i]={tempUser,tempIPaddress,tempRequestedSong,tempUserSongs};

First, in order to decalare an array of Strings, write
String[] record = new String[20]

Second, the context for a for loop is
(for INITIALIZATION;TEST;INCREMENT)
{
Body of loop
}

I think your for loop is messed up pretty bad

In order to initialize one member of your String array
write
record[i] = "" + tempUser + tempIPaddress + moreData;

the + operator can be used to concatenate Strings

Also, if your trying to store numerical values in some
usefull way, you should try setting up a User class
with fields for Ipaddress, song, etc.





Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us