Skip to content

Instantly share code, notes, and snippets.

@computingfreak
Last active March 9, 2019 23:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save computingfreak/366be7e94371aaa0ef0306ae630d8921 to your computer and use it in GitHub Desktop.
Save computingfreak/366be7e94371aaa0ef0306ae630d8921 to your computer and use it in GitHub Desktop.
import java.util.*;
public class collectionsortsublist
{
public static void sortsublist()
{
List<Integer> x=new ArrayList<Integer>();
x.add(1);
x.add(3);
x.add(2);
x.add(24);
x.add(5);
x.add(16);
Collections.sort(x.subList(3,5));
System.out.println(x);//[1, 3, 2, 5, 24, 16]
List<Integer> y=new ArrayList<Integer>();
y.add(1);
y.add(3);
y.add(2);
y.add(24);
y.add(5);
y.add(16);
Collections.sort(y.subList(3,6));
System.out.println(y);//[1, 3, 2, 5, 16, 24]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment