• Post Reply Bookmark Topic Watch Topic
  • New Topic

Need Help to Understand indexOf Return Value  RSS feed

 
Steve Dyke
Ranch Hand
Posts: 1783
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My code:



Return:

AbstractDisposition: newDispositionRecord: Running Message Function: 3
AbstractDisposition: newDispositionRecord: Running Message Function: 1,2,3,4,5
AbstractDisposition: newDispositionRecord: Running Message Function: -1
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
indexOf tells you where the target is found in the String. If it returns -1, it means it wasn't found.
 
Steve Dyke
Ranch Hand
Posts: 1783
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Keith Lynn wrote:indexOf tells you where the target is found in the String. If it returns -1, it means it wasn't found.


I understand that but my string is 1,2,3,4,5

And the value I am looking for is 3
 
Dave Tolls
Ranch Foreman
Posts: 3061
37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could QMSConfiguration be producing different results on the two constructor calls?

What classes are you dealing with here?

Does disp.getDispType return a String?
Does getValue() return a String?
 
Steve Dyke
Ranch Hand
Posts: 1783
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dave Tolls wrote:Could QMSConfiguration be producing different results on the two constructor calls?

What classes are you dealing with here?

Does disp.getDispType return a String?
Does getValue() return a String?


Thanks for the tip. I was looking for an int in the string.
 
Dave Tolls
Ranch Foreman
Posts: 3061
37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, but is the result of the two calls to that constructor the same?

If it were me I would have used a variable for QMSConfiguration and used the same object.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!