• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

indexOf() error

 
Momo Sawada
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello once again... i have a problem with my indexOf method.... i dont know why... it said in the API i can use it with the util. package.. but it doesn't run... can anyone help me please???
its at line 67...
codecodecode:


thank you very much!!!
 
Sean Clark
Rancher
Posts: 377
Android Java Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where did you declare your indexOf(..) method?

Or should it actually be link.indexOf(..)?

Sean
 
Momo Sawada
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
at line 67... i tried using it to get the index of the found element and replacing it with another in the same index....
 
Javad Rashidi
Ranch Hand
Posts: 34
Java MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you invoke this method on an String object. where is your String?
 
fred rosenberger
lowercase baba
Bartender
Posts: 12143
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Momo Sawada wrote:at line 67... i tried using it to get the index of the found element and replacing it with another in the same index....

on line 67, you CALL the indexOf() method, not declare it. If you call a method by simply typing the name, Java assumes you are trying to call a method defined in the current class. If you are trying to call the String class' indexOf method, you need to call it on a specific String.

What String is your 'r' supposed to be a substring of? you would need to change 67 to something like

int indx=myString.indexOf(r);

and replace 'myString' with whatever String you are searching.
 
Momo Sawada
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh... i see... thank you!!! i finally had my program running!!! Thank you very much!!!
 
fred rosenberger
lowercase baba
Bartender
Posts: 12143
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
glad we could help!
 
Campbell Ritchie
Sheriff
Pie
Posts: 49379
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Beware of long lines in code tags; they are difficult to read. And only use spaces for indentation, not tabs.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic