본문 바로가기

자바33

자바 열거형 Find Value 예전 코드와 데이터베이스에서 레거시 발견. 아무런 부가설명없이 1,2로 나눠져 있어서 유지보수에 어려움이 생길거라 생각. public enum PartnerInquiryTypes { Account(1), Name(2); private int value; PartnerInquiryTypes(int value) { this.value = value; } public static PartnerInquiryTypes findByValue(final int findValue){ return Arrays.stream(values()).filter(value -> value.value == findValue).findFirst().orElse(null); } public int getValue() { return v.. 2022. 9. 23.
자바 MessageFormat C#의 String.Format과 유사한 클래스 함수 Java MessageFormat.format("[{0}]{1}", "0 입력 문자열", "1 입력 문자열"); public static String format(String pattern, Object ... arguments) { MessageFormat temp = new MessageFormat(pattern); return temp.format(arguments); } C# String s = String.Format("The current price is {0} per ounce.", pricePerOunce); 2022. 5. 20.
Java 토마토 final static int[] xArray = {1, 0, -1, 0}; final static int[] yArray = {0, 1, 0, -1}; public static class Node { int x; int y; public Node(int x, int y) { this.x = x; this.y = y; } public void setX(int x) { this.x = x; } public void setY(int y) { this.y = y; } public int getX() { return this.x; } public int getY() { return this.y; } } public static void main(String[] args) { tomato(); } private .. 2021. 12. 20.
Java floodfill final static int[] xArray = {1, 0, -1, 0}; final static int[] yArray = {0, 1, 0, -1}; public static class Node { int x; int y; public Node(int x, int y) { this.x = x; this.y = y; } public void setX(int x) { this.x = x; } public void setY(int y) { this.y = y; } public int getX() { return this.x; } public int getY() { return this.y; } } public static void main(String[] args) { floodFill(); } priva.. 2021. 12. 15.