Driver code
public static void main ( String [ ] args ) { ArrayList < Integer > arr = new ArrayList < Integer > ( ) ; arr . add ( 3 ) ; arr . add ( 1 ) ; arr . add ( 4 ) ; arr . add ( 2 ) ; arr . add ( 5 ) ;