12:30 am - Tuesday October 24, 2017

Retrieve object from an index position Object get(int index)

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

BACK

                              This method returns the specified element in the array list based on the index value.

Example Program

import java.util.ArrayList;

public class Get {

	public static void main(String[] args)

	{

		ArrayList al = new ArrayList();

		System.out.println("Concepts in java:");

		al.add("Constructor");

		al.add("Inheritance");

		al.add("Polymorphism");

		al.add("Exceptional Handling");

		al.add("Casting");

		al.add("Packages");

		System.out.println(al);

		System.out.println("Get Function");

		String s = al.get(3);

		System.out.println("The element present in the index value 3 is:" + s);

	}

}

Output

   Concepts in java:

   [Constructor, Inheritance, Polymorphism, Exceptional Handling, Casting, Packages]

   Get Function

   The element present in the index value 3 is:Exceptional Handling

BACK

Filed in: Java Examples

Comments are closed.