본문 바로가기

Language93

Generics public class _01_Generics { public static void main(String[] args) { int[] iArray = { 1, 2, 3, 4, 5 }; double[] dArray = { 1.0, 2.0, 3.0, 4.0, 5.0 }; String[] sArray = { "A", "B", "C", "D", "E" }; printAnyArray(iArray); printAnyArray(dArray); printAnyArray(sArray); } private static void printAnyArray(T[] array) { for (T t : array) { System.out.print(t + " "); } System.out.println(); } } The prob.. 2023. 5. 29.
replace, replaceAll The 'replace' method can replace a specific character or a sequence of characters. public class Main { public static void main(String[] args) { String str = "Hello, World!"; // replace a single character String replacedStr = str.replace('H', 'J'); System.out.println(replacedStr); // prints "Jello, World!" // replace a sequence of characters (substring) replacedStr = str.replace("Hello", "Goodbye.. 2023. 5. 25.
Java Collections Framework The Java Collections Framework is a set of classes and interfaces that implement commonly reusable collection data structures. This includes List, Set, and Map interfaces, along with their various implementations like ArrayList, LinkedList, HashSet, TreeSet, HashMap, TreeMap, and others. Collection : This is the root interface in the Collection hierarchy. A collection represents a group of objec.. 2023. 5. 25.
Java access modifiers In Java, access modifiers are used to set the accessibility of classes, interfaces, variables, methods, constructors, etc. There are four types of Java access modifiers Private : The access level of a private modifier is only within the class.It cannot be accessed from outside the class. Default : The access level of a default modifier is only within the package. It cannot be accessed from outsi.. 2023. 5. 24.