• Post Reply Bookmark Topic Watch Topic
  • New Topic

String[][] can't be converted to int [] .. How to fix it???  RSS feed

 
Gabrielle Linkherz
Greenhorn
Posts: 26
Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Can you fixed it? I dont know the problem..

Example :

How many names do you want to input : 2

Name 1 : Boby Boly
Name 2 : John Joly

Name that you searched : Joly

Name Joly on 2
 
Dave Tolls
Ranch Foreman
Posts: 3061
37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What line is that error occurring on?
 
Ralph van Delft
Greenhorn
Posts: 11
Angular Framework Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On line 37 you call the 'search' method with a Integer and a String.

The method search is expecting twice an Integer.

solution for this:



EDIT:
I've got it wrong let me get back to you
 
Liutauras Vilda
Sheriff
Posts: 4917
334
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Would be a good improvement of a program if you'd change variable to something more meaningful than "s0", "a0", "bb", "xgme", "xgmeJ", "amountOfName". Also you do have variable "wantedName" but it is not initialized, so it looks a bit weird and confusing. "a0" variable every iteration gets incremented, so it has values a0 = 0 then 1, 2, 3... and you using this variable as index to access array position. So, name[a0] could access 4th element or any other based on the value it has at that moment, but variable name misleads you by having 0 in its name. I really think you have to change them to something better right now
 
Ralph van Delft
Greenhorn
Posts: 11
Angular Framework Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alright, second attempt.

There are several things wrong with your code.

First:
The search method has two Integer attributes.
On line 37 you give this method a String matrix and a String. So this cannot work.

Second.
On line 21 you have a null-pointer because on line 16 you have to say how many rows the array must have like:



I'm sorry for my bad English. (Dunglish ->mix of Dutch and English)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!