|
| 1 | +package gr.codelearn.core.showcase.oop.collections; |
| 2 | +import java.util.ArrayList; |
| 3 | +import java.util.Arrays; |
| 4 | +import java.util.HashMap; |
| 5 | + |
| 6 | +import static java.util.Arrays.sort; |
| 7 | + |
| 8 | +public class Main { |
| 9 | + |
| 10 | + public static void main(String[] args) { |
| 11 | + |
| 12 | + String[] appsArray = new String[5]; |
| 13 | + appsArray[0] = "word"; |
| 14 | + appsArray[1] = "excel"; |
| 15 | + appsArray[2] = "PowerPoint"; |
| 16 | + appsArray[3] = "MS Team"; |
| 17 | + appsArray[4] = "SharePoint"; |
| 18 | + |
| 19 | + // for (int i = 0; i < appsArray.length; i++) { |
| 20 | + // System.out.println(appsArray[i]); |
| 21 | + // } |
| 22 | + // |
| 23 | + // System.out.println(appsArray[1]); |
| 24 | + // |
| 25 | + // for(String s : appsArray){ |
| 26 | + // System.out.println(s); |
| 27 | + // } |
| 28 | + |
| 29 | + // float[] arr = new float[3]; |
| 30 | + // arr[0] = 3.2f; |
| 31 | + |
| 32 | + System.out.println(Arrays.toString(appsArray)); |
| 33 | + sort(appsArray); |
| 34 | + System.out.println(Arrays.toString(appsArray)); |
| 35 | + |
| 36 | + // ArrayList |
| 37 | + // ArrayList appList = new ArrayList(); // Object |
| 38 | + // ArrayList<String> appList = new ArrayList<>(); |
| 39 | + // appList.add("word"); |
| 40 | + // appList.add("excel"); |
| 41 | + // appList.add("powerpoint"); |
| 42 | + // appList.add(5); |
| 43 | + // String ls = (String) appList.get(0); |
| 44 | + // System.out.println(appList.get(0)); |
| 45 | + // System.out.println(appList.get(1)); |
| 46 | + |
| 47 | + // for (int i = 0; i < appList.size(); i++) { |
| 48 | + // System.out.println(appList.get(i)); |
| 49 | + // } |
| 50 | + // |
| 51 | + // for (String s : appList) { |
| 52 | + // System.out.println(s); |
| 53 | + // } |
| 54 | + |
| 55 | + // System.out.println(appList); |
| 56 | + // appList.remove("word"); |
| 57 | + // appList.remove(0); |
| 58 | + // System.out.println(appList); |
| 59 | + // System.out.println(appsArray); |
| 60 | + |
| 61 | + // ArrayList<Float> alFloat = new ArrayList<>(); |
| 62 | + // alFloat.add(12.7f); |
| 63 | + // float f = alFloat.get(0); |
| 64 | + |
| 65 | + // String s = new String("Hello"); |
| 66 | + // Double d = 3.6; |
| 67 | + // Double d1 = new Double(5.2); |
| 68 | + |
| 69 | + // HashMap<String, String> appMap = new HashMap<>(); |
| 70 | + // appMap.put("first", "word"); |
| 71 | + // appMap.put("second", "excel"); |
| 72 | + // appMap.put("third", "powerpoint"); |
| 73 | + // appMap.put("first", "powerpoint"); |
| 74 | + // |
| 75 | + // System.out.println(appMap); |
| 76 | + // System.out.println(appMap.get("second")); |
| 77 | + // |
| 78 | + // for (String key : appMap.keySet()) { |
| 79 | + // System.out.println(appMap.get(key)); |
| 80 | + // } |
| 81 | + // |
| 82 | + // for(String value : appMap.values()){ |
| 83 | + // System.out.println(value); |
| 84 | + // } |
| 85 | + } |
| 86 | +} |
0 commit comments