전체 글
-
-
Runnable 에서 변수 사용하기(final 를 변수처럼 사용하기)JAVA 2020. 11. 10. 07:42
Runnable 에는 final 상수밖에 사용을 못하는데 간혹 변수를 사용해야하는 경우가 있다 이럴 때, Runnable 을 리턴하는 함수를 만들고 이 함수를 호출하는 방식으로 사용하면 된다 예시를 보자! 간단한 예시로 stampValues 를 모두 출력하는 코드를 짜보자 ArrayList stampValues = {"1", "2", "3"}; // 사용하고자 하는 변수 private Runnable showRunnable(final int index, final Array stampValues) { Runnable run = new Runnable() { private int i = index; @Override public void run() { System.out.println(stampValues..
-
Visual Studio C#에서 폴더 탐색창, 파일 탐색창 띄우기C#(asp.net | asp.net core) 2020. 10. 30. 15:05
폴더 탐색창 띄우는 방법 1. Package Manager Console 창에서 Install-Package WindowsAPICodePack-Shell -Version 1.1.1 입력 후 Enter 2. 코드 입력 필요한 using 구문 using Microsoft.WindowsAPICodePack.Dialogs; // 폴더 오픈창 생성 및 설정 CommonOpenFileDialg dl = new CommonOpenFileDialog(); dl.IsFolderPicker = true; dl.Multiselect = true; // 폴더 탐색기를 열어서 열기를 눌렀을 때 string[] pathDirs = null; if(dl.ShowDialog() == CommonFileDialogResult.Ok) ..
-
GridLayout 에서 가로로 꽉 차게 하는 법(horizontal fill)JAVA/SWT 2020. 10. 12. 08:38
// Column 이 3개인 GridLayout 생성 Composite comp = new Composite(child, SWT.NONE); comp.setLayout(new GridLayout(3, true)); // 버튼 3개 생성 Button b1 = new Button(comp, SWT.NONE); b1.setText("1"); Button b2 = new Button(comp, SWT.NONE); b2.setText("2"); Button b3 = new Button(comp, SWT.NONE); b3.setText("3"); 버튼이 가로로 꽉 차도록 확장시켜보자 GridData gd = new GridData(SWT.FILL, SWT.NONE, true, false); b1.setLayoutD..
-
56번JAVA/leetcode 2020. 8. 25. 16:04
package algorithmStudy; public class Test56 { public static void main(String[] args) { Solution56 sol = new Solution56(); int[][] input = {{1, 3}, {2, 6}, {8, 10}, {15, 18}, {10, 12}, {20,23}}; int[][] output = sol.merge(input); for(int i = 0; i < output.length; i++) { System.out.println(output[i][0] + ", " + output[i][1]); } System.out.println(); int[][] input2 = {{1, 4}, {2, 3}}; int[][] outpu..
-
49번JAVA/leetcode 2020. 8. 24. 23:22
package algorithmStudy; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; public class Test49_cwk { public static void main(String[] args) { String[] input = {"eat", "tea", "tan", "ate", "nat", "bat"}; Solution49 sol = new Solution49(); List anagrams = sol.groupAnagrams(input); System.out.println("["); for(int i = 0; i < a..
-
ArrayList 객체 비교하기JAVA 2020. 7. 20. 10:26
객체가 담긴 ArrayList 가 동일한지 비교하는 구문이다 loopFalse: for(PartInformationData vm_data : vm_partmaster) { loopTrue: for(PartInformationData setItemNo_data : setItemNoDataExtract) { dataSame = equals(vm_data, setItemNo_data); // 하나라도 일치할 때 다음 vm_data 를 불러온다 if(dataSame) { break loopTrue; } } // 하나라도 일치하는 게 없다면 반복문 종료한다 if(!dataSame) { break loopFalse; } } private boolean equals(PartInformationData vm_data,..
-
Lambda 식 / ArrayList를 사용한 Stream 연산JAVA 2020. 5. 28. 20:09
고객 Class public class Customer { private String name; private int age; private int price; public Customer(String name, int age, int price) { super(); this.name = name; this.age = age; this.price = price; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } public int g..