|
-
September 25th, 2000, 10:03 AM
#1
Array Lookup?
How do you lookup array elements in Java?
Have String{} MyArray = { txt1, txt2, txt3 };
if I have myVar and want to check if it is in MyArray...
-
September 25th, 2000, 01:12 PM
#2
Re: Array Lookup?
Hi, u can lookup array just like this..
If u have an String array like this, and u want to lookup "myVar" in that array,
String[] arr = {"txt1","txt2","myVar"};
for ( int i=0; i<arr.length; i++ )
{
if ( arr[i] == "myVar" )
{
System.out.println(arr[i]);
}
}
Sreeni
#If this post is valid to u, then dont forget to rate it#
-
September 26th, 2000, 12:26 PM
#3
Re: Array Lookup?
Avoid the == when you mean .equal
str.equal("txt1")
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|