×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Added: May 5, 2021 10:39 AM
Views: 3969
Tags: collections
  1.     public static void main(String[] args) {
  2.  
  3.         ArrayList<String> colors = new ArrayList<>();
  4.  
  5.         colors.add("Red");
  6.         colors.add("Green");
  7.         colors.add("Orange");
  8.         colors.add("White");
  9.         colors.add("Black");
  10.  
  11.  
  12.         //Element an spez. Index abrufen und in einer Variable speichern
  13.         String firstElement = colors.get(0);
  14.         System.out.println("First Element: " + firstElement);
  15.         String element = colors.get(2);
  16.         System.out.println("Specific Element: " + element);
  17.  
  18.     }