Last active
March 9, 2019 23:38
-
-
Save computingfreak/366be7e94371aaa0ef0306ae630d8921 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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