5:36 pm - Thursday August 17, 2017

Reverse the order of elements in collection using public static void reverse(list list)

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

                          The method is used to reverse the order of the elements in the specified list.

Example Program

import java.util.Collections;

import java.util.HashMap;

import java.util.Map;

public class collectionCheckedMap

{

	public static void main(String[] args)

	{

		HashMap<String, String> a = new HashMap<String, String>();

		a.put("1", "Happy");

		a.put("2", "Joy");

		Map<String, String> p;

		p = Collections.checkedMap(a, String.class, String.class);

		System.out.println("typesafe view of the map: " + p);

	}
}

Output

  Normal list:[1, 2, 3, 4]

   Reverse list:[4, 3, 2, 1]

BACK

Filed in: Java Examples

Comments are closed.