|
| 1 | +import java.util.*; |
| 2 | + |
| 3 | +public class Variables { |
| 4 | + |
| 5 | + public static void main(String[] args) { |
| 6 | + int[] a = new int[100000]; |
| 7 | + Integer intObj = new Integer(20); |
| 8 | + Float floatObj = new Float("1.354"); |
| 9 | + Character character = new Character('a'); |
| 10 | + Boolean bool = new Boolean(true); |
| 11 | + |
| 12 | + Map<String, String> emptyMap = new HashMap<>(); |
| 13 | + Map<String, Integer> bookset = new LinkedHashMap<>(); |
| 14 | + bookset.put("Algorithm Introduction", 60); |
| 15 | + bookset.put("Thinking in JAVA", 50); |
| 16 | + |
| 17 | + Map<String, Map<String, Integer>> smallStore = new HashMap<>(); |
| 18 | + smallStore.put("Computer Science", bookset); |
| 19 | + |
| 20 | + Map<String, Map<String, Integer>> bigStore = new HashMap<>(); |
| 21 | + for (int i = 0; i < 100000; i++) { |
| 22 | + bigStore.put("key" + i, bookset); |
| 23 | + } |
| 24 | + |
| 25 | + List<String> smallList = Arrays.asList("Algorithm Introduction"); |
| 26 | + List<String> bigList = new ArrayList<>(); |
| 27 | + for (int i = 0; i < 100000; i++) { |
| 28 | + bigList.add("key" + i); |
| 29 | + } |
| 30 | + |
| 31 | + School school = new School(); |
| 32 | + Person person = new Person(); |
| 33 | + Person person1 = null; |
| 34 | + Employee employee = new Employee(); |
| 35 | + StringException stringException = new StringException(); |
| 36 | + NullString nullString =new NullString(); |
| 37 | + Date date = new Date(); |
| 38 | + String name = "Test"; |
| 39 | + System.out.println("Exit."); |
| 40 | + } |
| 41 | + |
| 42 | + public static class School { |
| 43 | + String name = "test"; |
| 44 | + |
| 45 | + } |
| 46 | + |
| 47 | + public static class Person { |
| 48 | + String name = "jinbo"; |
| 49 | + |
| 50 | + @Override |
| 51 | + public String toString() { |
| 52 | + return "Person [name=" + name + "]"; |
| 53 | + } |
| 54 | + } |
| 55 | + |
| 56 | + public static class Employee extends Person { |
| 57 | + |
| 58 | + } |
| 59 | + |
| 60 | + public static class StringException { |
| 61 | + |
| 62 | + @Override |
| 63 | + public String toString() { |
| 64 | + throw new RuntimeException("Unimplemented method exception"); |
| 65 | + } |
| 66 | + } |
| 67 | + |
| 68 | + public static class NullString { |
| 69 | + |
| 70 | + @Override |
| 71 | + public String toString() { |
| 72 | + return null; |
| 73 | + } |
| 74 | + } |
| 75 | +} |
0 commit comments