• Post Reply Bookmark Topic Watch Topic
  • New Topic

Issues with searching through Array List  RSS feed

 
Nikki Harding
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys! I'm working on an assignment where we have to make a bank application. The part I'm stuck on is where you can search for a particular account by the name of the person. When I print account info by account number, it prints out fine including the name. But, when I directly search for the name, it says the account doesn't exist. Can someone please help me see my logic error? Thanks in advance!

Here's just the case that deals with searching by name. I can post more if needed.
Accounts look like: 1234, Mary, $100
 
Junilu Lacar
Sheriff
Posts: 11493
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nikki Harding wrote:Can someone please help me see my logic error?

One thing that makes it difficult to follow the logic in your code is the poor formatting and indentation.

Please pick one of the many Java Style Guides available freely out there and follow one consistently. If you're using an IDE like Eclipse, it's even easier. Just press CTRL+SHIFT+F to auto-format your code and, viola!, it should be much more readable.
 
Junilu Lacar
Sheriff
Posts: 11493
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't use == to compare objects for equality. Using == with objects is called "reference equality" which basically checks if the left side references the same object as the right side. When checking for object equality, you should use the equals() method instead.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!