In this section of JRuby tutorial you will learn how to create and add elements in ArrayList using the JRuby. ArrayList is used to store elements in the list which can be accessed sequentially.
In this example of ArrayList we have to include the ArrayList class as we import class file in simple java program. After including ArrayList we have created a new instance of ArrayList so that we can call add method of this class to add elements in it.
arrlist = ArrayList.new
First line in ArrayList.rb file require "java" means that we are making our program enabled to use java classes and method. "puts" method prints array list on the console.
[Amit, Kumar, Vineet]
Rs. 20,000 US$ 300
Today: Rs. 10,000 US$150
Course Duration: 30 hrs
Posted on: September 30, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles