Win a copy of Machine Learning Systems: Designs that scale this week in the Scala forum
or Xamarin in Action: Creating native cross-platform mobile apps in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

array  RSS feed

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am a new member of this forum.so i would like to know about array very clearly and simple.
thanks a lot.
emran.
 
Chicken Farmer ()
Ranch Hand
Posts: 1932
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Depends on what you mean by array. You can look in the API at Array, or ArrayList, or whatever and get a good understanding of classes of Arrays
http://java.sun.com/products/jdk/1.2/docs/api/index.html
If you are meaning an array of objects or simple values, it's just really a collection of similar things, and each item in the collection is designated by an index, with the first item being 0, the next being 1, etc.
For instance, if I want to have a group of names, I could do something like:

This is a simple example, and this is not the only way to initialize an array.
Since arrays always start at 0, "Ted" is at index 0, "Fred" is at 1, "Tim" is at 2, and "Jim" is at 3.
If I wanted to print out the last name in the array, I would do:

That's pretty much the basics of arrays, though there are a lot of more complicated things you can do with them.
What's your experience so far with arrays? If you are new to Java, or programming in general, check out http://www.javaranch.com/books.jsp for a listing of good books.
Jason

[This message has been edited by jason adam (edited September 01, 2001).]
 
Paper beats rock. Scissors beats tiny ad.
Rocket Oven Kickstarter - from the trailboss
https://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!