SHARE
TWEET

Java Map Thing

a guest Dec 2nd, 2019 107 in 9 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.ArrayList;
  2. import java.util.Map;
  3. import java.util.HashMap;
  4.  
  5. // one class needs to have a main() method
  6. public class HelloWorld
  7. {
  8.   // arguments are passed using the text field below this editor
  9.   public static void main(String[] args)
  10.   {
  11.     ArrayList<Integer> list = new ArrayList<>();
  12.     Map<String, Integer> map = new HashMap<>();
  13.     int counter = 0;
  14.    
  15.     list.add(2);
  16.     list.add(3);
  17.     list.add(40);
  18.    
  19.     for (int i : list) {
  20.         map.put("key " + counter, i);
  21.         counter++;
  22.     }
  23.   }
  24. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top