• Post Reply Bookmark Topic Watch Topic
  • New Topic

Need help with boolean search with 2d array  RSS feed

 
Karine Roy
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm having a problem with finding a match in my 2d array with an answer provided with the user.

I know my code is not complete but I am trying to get menu option #1 to work. Can anyone help me?

Also, I have no idea how to set my code with the numbers on the side, can you let me know how to do this?

 
Yogesh Gnanapraksam
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this code in your partsCheck method



You will understand how two dimensional arrays are represented in java.
 
Campbell Ritchie
Marshal
Posts: 56599
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the search logic you are using? Can you write it down on paper and get it into words of one syllable? Can you get the search to work when you isolate it from the rest of your code?

By the way: an array of arrays of part number against price is very much non-object-oriented programming. you should consider a Part class encapsulating the number and description and price. You should consider a Map from part number to part.
 
Karine Roy
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your help! I figured it out. The .equal() only works on strings, I had integers!
 
Campbell Ritchie
Marshal
Posts: 56599
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's not .equal() but .equals(). It works on all reference types, because it is declared in Object. For primitives you use the == operator. An int is a primitive, an integer might or might not be a primitive.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!