Article View: borland.public.jbuilder.java.language
Article #8339Newbie problem Help
From: Jips
Date: Sun, 01 Apr 2001 16:57
Date: Sun, 01 Apr 2001 16:57
57 lines
2264 bytes
2264 bytes
I have an array of 7 strings containing surnames, I want the user to input
the name they are looking for and then search through the array to find the
corresponding record. I can't get the input string to compare to the array
string.
Please help as this has to be really easy but..................
Cheers James
{
public static void main (String args[])
{
//declaring variables
//Strings
String [] userName = {"Adams","Johnson","Matthews","Peters","Smith",
"Townsend","Wilson"};
String userSearch;
String tempString;
//Integers
int index = 0;
//Double
double [] userFine = {0.40,0.25,1.36,2.25,0.00,1.10,0.00};
//search
{
userSearch = JOptionPane.showInputDialog(null,"Enter name: ","Input
Box",JOptionPane.PLAIN_MESSAGE);
for (index = 0; index < 7;)
{
tempString=userName[index];
if (tempString == userSearch)
{
JOptionPane.showMessageDialog(null,"Looking for :
"+userSearch+" Name Found: "+tempString+" found continuing on");
}
else
{
JOptionPane.showMessageDialog(null,"Looking for :
"+userSearch+" Name Found: "+tempString+" looking going back around");
index++;
}
}
System.exit(0);
}
}
}
Technical Details
Message-ID:
<tcenh9ll114k7b@corp.supernews.co.uk>Path:
arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!news.tele.dk!195.224.25.10!sn-uk-xit-01!sn-uk-post-01!supernews.com!corp.supernews.co.uk!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,97680a906a0b92c1,start X-Google-Attributes: gidf74b3,public X-Google-ArrivalTime: 2001-04-01 10:01:02 PST Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!news.tele.dk!195.224.25.10!sn-uk-xit-01!sn-uk-post-01!supernews.com!corp.supernews.co.uk!not-for-mail From: "Jips" <James_Blonden@Bigfoot.com> Newsgroups: borland.public.jbuilder.java.language Subject: Newbie problem Help Date: Sun, 1 Apr 2001 17:57:39 +0100 Organization: Posted via Supernews, http://www.supernews.com Message-ID: <tcenh9ll114k7b@corp.supernews.co.uk> X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 X-Complaints-To: newsabuse@supernews.com Lines: 59