Java Programming ArrayList Ques?

Well i'm doing a program to search the arraylist for the specific string.

friends = arraylist

currently my arraylist contains lots of information

etc of it

name: John number: 123

name: Bruce number: 242

currently my program kepts moves to the else statement, I hope someone could help me on this. Is there a way to search the arraylist without a complete match ?

for (int i = 0; i < friends.size(); i++)

{

if (friends.contains("Bruce"))

{

System.out.println(friends.get(i).toString());

}

else

{

System.out.println ("No Records Found");

}

}

Update:

yes , its string

Please enter comments
Please enter your name.
Please enter the correct email address.
You must agree before submitting.

Answers & Comments


Helpful Social

Copyright © 2024 QUIZLS.COM - All rights reserved.