Monthly Archives: May 2014

Find the second smallest element in java

import java.util.ArrayList; import java.util.Collections;   public class SmallestNumber { public static void main(String[] args) {   ArrayList<Integer> list=new ArrayList<Integer>(); list.add(10); list.add(8); list.add(3); list.add(11); list.add(7); Collections.sort(list); System.out.println(“Second Smallest¬†element is “+list.get(1)); } }

Posted in Uncategorized | Tagged , , , , | Leave a comment