Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

indexOf  RSS feed

 
abalfazl hossein
Ranch Hand
Posts: 635
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://www.cs.duke.edu/csl/docs/jgl/api/COM.objectspace.jgl.examples.ArrayExamples.html

I think there is a problem in their code:

/**
* Counting, finding, replacing, removing.
*
* @see COM.objectspace.jgl.Array
* @version 2.0.1
* @author ObjectSpace, Inc.
*/



array.indexOf( "bat" );!!

Is it right?
 
fred rosenberger
lowercase baba
Bartender
Posts: 12542
48
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is an error...the above code won't compile.
 
Henry Wong
author
Sheriff
Posts: 23283
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
abalfazl hossein wrote:http://www.cs.duke.edu/csl/docs/jgl/api/COM.objectspace.jgl.examples.ArrayExamples.html

I think there is a problem in their code:

/**
* Counting, finding, replacing, removing.
*
* @see COM.objectspace.jgl.Array
* @version 2.0.1
* @author ObjectSpace, Inc.
*/

array.indexOf( "bat" );!!

Is it right?


Well, I googled and found the javadoc for the Array class in question...

http://www.cs.duke.edu/csl/docs/jgl/api/COM.objectspace.jgl.Array.html

That line of code does look valid -- meaning there is a indexOf() method, and it takes an object, which a string is.

Henry
 
Ruud Smith
Greenhorn
Posts: 11
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
fred rosenberger wrote:There is an error...the above code won't compile.


You'll probably need the COM.objectspace.jgl package for that. I've tried to find it, but it seems that it's not freely available anymore.

 
Campbell Ritchie
Marshal
Posts: 55717
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That so‑called Array class appears to be a List. It has been enhanced with methods which count how many instances of a particular object it contains. You can probably create such a class yourself with a List implementation like ArrayList.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!