Simple problem

Thread Solved

Join Date: Apr 2006
Posts: 114
Reputation: KimJack is an unknown quantity at this point 
Solved Threads: 0
KimJack KimJack is offline Offline
Junior Poster

Simple problem

 
0
  #1
Mar 5th, 2008
Can someone tell me how to correct this?

  1. for(int i = 0; i < 7; i ++)
  2. {
  3. if(team.group.toys[i].getName().equalsIgnoreCase(name )
  4. {
  5. team.insert(team.group.toys[i].getDescrip());
  6. System.out.println("OK");
  7. }
  8. }
  9. System.out.println("Is not included.");

This is so simple that I cannot figure out what the problem is. I need "OK" to print if the getName() equals name. If they do not equal print "Is not included".

I normally don't have problems with this but I have swapped and tried everything, I know that is is something simple.

Thank you,
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,433
Reputation: Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of 
Solved Threads: 507
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is online now Online
Industrious Poster

Re: Simple problem

 
0
  #2
Mar 5th, 2008
Just to clarify the question, the printing of "Ok" part works fine if the match is found, but you don't want it to also print "not included"?
Last edited by Ezzaral; Mar 5th, 2008 at 6:24 pm.
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,433
Reputation: Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of 
Solved Threads: 507
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is online now Online
Industrious Poster

Re: Simple problem

 
0
  #3
Mar 5th, 2008
  1. String result = "Is not included.";
  2. for(int i = 0; i < 7; i ++)
  3. {
  4. if(team.group.toys[i].getName().equalsIgnoreCase(name )
  5. {
  6. team.insert(team.group.toys[i].getDescrip());
  7. result = "OK";
  8. break; // no reason to keep looking here
  9. }
  10. }
  11. System.out.println(result);
Last edited by Ezzaral; Mar 5th, 2008 at 6:25 pm.
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 114
Reputation: KimJack is an unknown quantity at this point 
Solved Threads: 0
KimJack KimJack is offline Offline
Junior Poster

Re: Simple problem

 
0
  #4
Mar 5th, 2008
Thanks Ezzaral.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC