fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. List<Integer> list = Arrays.asList(1, 2, 3, 4, 5);
  13. list.set(1, 6);
  14.  
  15. System.out.println("oh, ez mutable!");
  16.  
  17. for(Integer i : list){
  18. System.out.println(i.toString());
  19. }
  20.  
  21. try{
  22. list.add(7);
  23. } catch (Exception e){
  24. System.out.println("... de fixed size");
  25. }
  26. }
  27. }
Success #stdin #stdout 0.1s 321600KB
stdin
Standard input is empty
stdout
oh, ez mutable!
1
6
3
4
5
... de fixed size