| 34 | return result.toString(); |
| 35 | } |
| 36 | public static void main(String[] args) { |
| 37 | AssociativeArray<String,String> map = |
| 38 | new AssociativeArray<>(6); |
| 39 | map.put("sky", "blue"); |
| 40 | map.put("grass", "green"); |
| 41 | map.put("ocean", "dancing"); |
| 42 | map.put("tree", "tall"); |
| 43 | map.put("earth", "brown"); |
| 44 | map.put("sun", "warm"); |
| 45 | try { |
| 46 | map.put("extra", "object"); // Past the end |
| 47 | } catch(ArrayIndexOutOfBoundsException e) { |
| 48 | System.out.println("Too many objects!"); |
| 49 | } |
| 50 | System.out.println(map); |
| 51 | System.out.println(map.get("ocean")); |
| 52 | } |
| 53 | } |
| 54 | /* Output: |
| 55 | Too many objects! |