Core Java - Collections - Interview Questions and Answers

Revision as of 09:03, 13 June 2018 by Rasimsen (talk | contribs) (Created page with "===What happens when you compile and run the below program?=== <syntaxhighlight lang="java"> package com.javatutorial.quiz; import java.util.ArrayList; import java.util.Arra...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

What happens when you compile and run the below program?

package com.javatutorial.quiz;
 
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
 
public class Quiz38 {
 
    public static void main(String[] args) {
 
        List<Integer> list = new ArrayList<Integer>();
        
        Integer[] arr = {2,10,3};
        
        list = Arrays.asList(arr);
        
        list.set(0, 3);
        
        System.out.println(list);
        
        list.add(1);
        
        System.out.println(list);
    }
 
}