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

Variable of ArrayList  RSS feed

 
Harold Lauder
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


This is code of seafight from Java Head First. I hope you guys know him, because I can describe all of this. This code works fine but I can't understand what exactly is going on in this string: 94
int index = locationCells.indexOf(userInput);

Here's my poor explanations:
We have a int value "index". We are call to variable of ArrayList and say to this variable  that she ought to define index of userInput. Is this correct?
 
praveen kumaar
Ranch Hand
Posts: 461
22
Android Chrome Eclipse IDE Google App Engine Java Notepad Oracle Ubuntu Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
by doing so,you are checking inside the locationcell that whatever
user has input is either present or not inside the list.if it is present it returns the index of first occurence of input inside list and -1 if it is not present.
 
praveen kumaar
Ranch Hand
Posts: 461
22
Android Chrome Eclipse IDE Google App Engine Java Notepad Oracle Ubuntu Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And a warm welcome to ranch Harold!
 
Norm Radder
Ranch Foreman
Posts: 2240
28
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have a link to the API doc?
http://docs.oracle.com/javase/8/docs/api/index.html

That is the place to go to find out what different methods do.  Find the class in the lower left frame, click on it and the class's API doc is shown in the main frame.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!