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]
Liked it! Share this Tutorial