|
-
new programmer question about array string searching
Following is a code I am trying to make it work for learning purposes. tf1,tf2,tf5
are Textfield, rs database, data is array object
I am trying to search for a string in textfield tf5 when ever I press search
button. This code does find
the string I am looking for but it continues to search and always displays
the last item on the array. Whats wrong with this
code I can't seem to solve the problem. any help would be appreciated.
String m=" ";
m=tf5.getText(); //get the string from textfield
for (int i=0; i<rs.n; i++){
if (rs.data[i].lLast.equals(m)) //here it looks as it found the text
and then continues as if did not find anything
tf1.setText(rs.data[i].lLast);
tf2.setText(rs.data[i].fFirst);
/tf5.setText("");
}
}
class database {
Record rs=new Record();
public Record[] data = new Record[1000];
public int n=0;
public void store (Record rs) { //store String lLast,fFirst,sSS,aAge
data[n] =rs;
n++;
}
}
THanks
sudhir kapoor
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
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks