Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class myClass {
- public static void main(String[] args){
- // Create an array and convert to list
- Character[] ray = {'p', 'w', 'n', 's'};
- List<Character> l = Arrays.asList(ray);
- System.out.println("Original : ");
- System.out.println(l);
- // Reverse and print list
- Collections.reverse(l);
- System.out.println("Reverse : ");
- System.out.println(l);
- // Create a new array and a new list
- Character[] newRay = new Character[l.size()];
- List<Character> listCopy = Arrays.asList(newRay); // Blank list with predetermined size
- Collections.copy(listCopy, l);
- System.out.println("After copy : ");
- System.out.println(listCopy);
- // Fill
- Collections.fill(l, 'X');
- System.out.println("Fill with 'X' : ");
- System.out.println(l);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement