Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

problem with finding index of a string?  RSS feed

 
J radolf
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Hi my requirement is i should find the index of string whcih is entered in the command line and it should count from the list i put in collection.

i know to see the index from the command line but how to count with respect to the values entered in list?
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"January Radolf"
Please check your private messages for an important administrative matter.
 
santhosh.R gowda
Ranch Hand
Posts: 296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[MG]Edited content. Please do not provide ready made answers. Ref David's post below
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
NotACodeMill

Don't just blindly supply answers: the point is to help people learn, and learn how to learn, not do their work for them. If the OP was in a class, for example, you just did their homework for them.

(Btw, I knew someone named January once. And Carrot. One never knows...)
 
santhosh.R gowda
Ranch Hand
Posts: 296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please do not provide ready made answers.



Sorry for binding the answer.But i had not given any ready made answers please don't think that people will give ready made answers .
 
anandhi mohan
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use this to get the list index for your given input.

int c= l.indexOf(a);
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
anandhi mohan wrote:use this to get the list index for your given input.

int c= l.indexOf(a);

List has an indexOf() method?
 
anandhi mohan
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Newton wrote:
anandhi mohan wrote:use this to get the list index for your given input.

int c= l.indexOf(a);

List has an indexOf() method?


yes, list has this method.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Whoops, I was looking at Collection--never mind.

Still shouldn't blindly provide answers, though: provide resources, assist the poster's thought process, etc. Handing them solutions on a plate serves no one.
 
J radolf
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey thanks guys for your answers.But i had got the answer myself.

should tell you one thing. Working in a IDE helps you a lot.

because all the available methods are listed
 
Henry Wong
author
Sheriff
Posts: 22840
119
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay... the side discussion topic (about giving out answers) has been split from this topic...

http://www.coderanch.com/t/450157/Ranch-Office/with-finding-index-string


This topic can now return to talking about the original subject.

Henry
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!