JAVA
-
[JAVA] 여러 type 섞인 이중 리스트 List<List<Object>> transpose (전치) 하는 법JAVA 2022. 9. 14. 21:01
table 모양으로 String 또는 Integer type 등으로 섞인 이중 리스트를 transpose (전치) 하고 싶을때가 있다. 이럴때는 아래와 같이 transpose 함수를 만들어 치환하면 된다. import java.util.*; public class MyClass { public static void main(String[] args) { // Object table 생성 List table = new ArrayList(); table.add(new ArrayList(Arrays.asList("id", "name", "email"))); table.add(new ArrayList(Arrays.asList(1, "abc", "a@"))); table.add(new ArrayList(Array..
-
[JAVA] List<List<Integer>> 이중 리스트 transpose (전치) 하는법JAVA 2022. 9. 14. 20:56
table 모양으로 Integer type으로 적힌 이중 리스트를 transpose (전치) 하고 싶을때가 있다. 이럴때는 아래와 같이 transpose 함수를 만들어 치환하면 된다. import java.util.*; public class MyClass { public static void main(String[] args) { // table 생성 List table = new ArrayList(); table.add(new ArrayList(Arrays.asList(1, 2, 3))); table.add(new ArrayList(Arrays.asList(4, 5, 6))); table.add(new ArrayList(Arrays.asList(7, 8, 9))); // 전치전 System.out.p..
-
[JAVA] List<List<String>> 이중 리스트 transpose (전치) 하는 법JAVA 2022. 9. 14. 20:49
table 모양으로 String type으로 적힌 이중 리스트를 transpose (전치) 하고 싶을때가 있다. 이럴때는 아래와 같이 transpose 함수를 만들어 치환하면 된다. import java.util.*; public class MyClass { public static void main(String[] args) { // table 생성 List table = new ArrayList(); table.add(new ArrayList(Arrays.asList("id", "name", "email"))); table.add(new ArrayList(Arrays.asList("1", "abc", "a@"))); table.add(new ArrayList(Arrays.asList("2", "def..
-
[JAVA] List min/max 최소값/최대값 찾기JAVA 2022. 9. 14. 20:26
List 값중 최대/최소값을 찾기 위해서 아래 두 함수를 사용하면 된다. 최대값 => Collections.max() 최소값 => Collections.min() ex) List list = new ArrayList(Arrays.asList(1,2,3)); // 최대값 int maxValue = Collections.max(list); System.out.println(maxValue); // 최소값 int minValue = Collections.min(list); System.out.println(minValue);