java 10

Java, Kotlin Coding conventions

Java convention https://naver.github.io/hackday-conventions-java/ ์บ ํผ์Šค ํ•ต๋ฐ์ด Java ์ฝ”๋”ฉ ์ปจ๋ฒค์…˜ ์ค‘๊ด„ํ˜ธ({,}) ๋Š” ํด๋ž˜์Šค, ๋ฉ”์„œ๋“œ, ์ œ์–ด๋ฌธ์˜ ๋ธ”๋Ÿญ์„ ๊ตฌ๋ถ„ํ•œ๋‹ค. 5.1. K&R ์Šคํƒ€์ผ๋กœ ์ค‘๊ด„ํ˜ธ ์„ ์–ธ ํด๋ž˜์Šค ์„ ์–ธ, ๋ฉ”์„œ๋“œ ์„ ์–ธ, ์กฐ๊ฑด/๋ฐ˜๋ณต๋ฌธ ๋“ฑ์˜ ์ฝ”๋“œ ๋ธ”๋Ÿญ์„ ๊ฐ์‹ธ๋Š” ์ค‘๊ด„ํ˜ธ์— ์ ์šฉ๋˜๋Š” ๊ทœ์น™์ด๋‹ค. ์ค‘๊ด„ํ˜ธ naver.github.io Kotlin convention https://kotlinlang.org/docs/coding-conventions.html#class-layout Coding conventions | Kotlin kotlinlang.org ์ฝ”๋”ฉํ•  ๋•Œ ์ฐธ๊ณ ํ•˜๋Š” convention ๋ฌธ์„œ๋“ค! Java๋ž‘ Kotlin ์นดํ…Œ๊ณ ๋ฆฌ ๋‘˜ ์ค‘ ์–ด๋””๋‹ค ๋„ฃ์„์ง€..

์•ˆ๋“œ๋กœ์ด๋“œ Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8

Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8 ์•ˆ๋“œ๋กœ์ด๋“œ ์ŠคํŠœ๋””์˜ค ArticFox๋ฒ„์ „๋ถ€ํ„ฐ Compose๊ฐ€ ๋„์ž…๋˜๋ฉด์„œ ์ด๋Ÿฐ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒ๋˜๋Š” ๊ฒƒ์œผ๋กœ ์•Œ๊ณ  ์žˆ๋‹ค. Compose ํ”„๋กœ์ ํŠธ ๋งŒ๋“ค ๋•Œ๋งˆ๋‹ค ์ด๋Ÿฌ๋‹ˆ๊นŒ ์ •๋ง ๊ท€์ฐฎ๋‹ค์•„ . . . ๐Ÿถ ์›์ธ์€ ์ ํ˜€์žˆ๋Š” ๊ทธ๋Œ€๋กœ๋‹ค. Java์˜ JDK๋ฅผ ์ƒ˜์†ก๋•Œ๋ฌธ์— Java 1.8๋กœ ํ•ด๋†”์„œ ๊ทธ๋Ÿฐ ๊ฑฐ์˜€๋‹ค. ํ˜น์‹œ Java 11์ด ์•ˆ ๊น”๋ ค์žˆ๋‹ค๋ฉด, ์š”๊ธฐ๋กœ ๊ฐ€์„œ ๋‹ค์šด ๋ฐ›์œผ์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค. (์ €๋„ ์—ฌ๊ธฐ์„œ ๋‹ค์šด ๋ฐ›์•˜์Šต๋‹ˆ๋‹ค . . ) https://www.oracle.com/java/technologies/downloads/#java11 ์ž ์ด์ œ ์ง„์งœ ์‹œ์ž‘! โ‘  File - Project Structure..

Android 2022.07.04

Java ์ž๋ฐ” 2์ฐจ์› ๋ฐฐ์—ด ์ถœ๋ ฅํ•˜๊ธฐ

Java ์ž๋ฐ” 2์ฐจ์› ๋ฐฐ์—ด ์ถœ๋ ฅํ•˜๊ธฐ ์•Œ๊ณ ๋ฆฌ์ฆ˜์„ ํ•˜๋‹ค ๋ณด๋ฉด 2์ฐจ์› ๋ฐฐ์—ด์„ ํ•œ๋ˆˆ์— ๋ณด๊ณ  ์‹ถ์„ ๋•Œ๊ฐ€ ์žˆ๋‹ค. ์ด๋Ÿด ๋•Œ ์‚ฌ์šฉํ•˜๋Š” ๋ฉ”์„œ๋“œ! ๋งค๋ฒˆ ๋งŒ๋“ค๊ธฐ ๊ท€์ฐฎ์•„์„œ ๋ธ”๋กœ๊ทธ์— ๊ธฐ๋กํ•ด๋‘”๋‹ค.๐Ÿ˜— public static void print2d(int[][] result) { int m = result.length; int n = result[0].length; for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { System.out.print(result[i][j] + "\t"); } System.out.println(); } System.out.println("----------------------"); }

Java 2021.07.18

Java ์ž๋ฐ” ๋ฆฌ์ŠคํŠธ ์ •๋ ฌํ•˜๊ธฐ

Java ์ž๋ฐ” ๋ฆฌ์ŠคํŠธ ์ •๋ ฌํ•˜๊ธฐ ์˜ค๋ฆ„์ฐจ์ˆœ ์ •๋ ฌ Collections.sort(list, Comparator.naturalOrder()); list.sort(Comparator.naturalOrder()); ๋‚ด๋ฆผ์ฐจ์ˆœ ์ •๋ ฌ Collections.sort(list, Comparator.reverseOrder()); list.sort(Comparator.reverseOrder()); ๋‘ ๊ฐ€์ง€ ๋ฐฉ๋ฒ• ๋ชจ๋‘ ๋‹ค ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•˜๋‹ค.

Java 2021.06.28

Java ์ž๋ฐ” ๋ž˜ํผ ํด๋ž˜์Šค

Java ์ž๋ฐ” ๋ž˜ํผ ํด๋ž˜์Šค int, long, double ๋“ฑ ๊ธฐ๋ณธํ˜• ๋ฐ์ดํ„ฐ ํƒ€์ž…๋“ค์€ ์ž์‹ ์˜ ๋ฉ”์„œ๋“œ๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ์ง€ ์•Š๋‹ค. ํ•˜์ง€๋งŒ ํ”„๋กœ๊ทธ๋ž˜๋ฐ์„ ํ•˜๋‹ค ๋ณด๋ฉด ๊ธฐ๋ณธํ˜• ๋ฐ์ดํ„ฐ์— ๋Œ€ํ•ด ๋ณ€ํ™˜ํ•ด์•ผ ํ•˜๋Š” ์ƒํ™ฉ์ด ๋งŽ๋‹ค. (String์œผ๋กœ ๋ณ€ํ™˜ ๋“ฑ) ์ด๋Ÿด ๋•Œ ๋ฐ์ดํ„ฐ ๋ณ€ํ™˜์„ ๋„์™€์ฃผ๋Š” ๊ฒƒ์ด ์ž๋ฐ”์˜ ๋ž˜ํผ ํด๋ž˜์Šค์ด๋‹ค. ๋ž˜ํผ ํด๋ž˜์Šค์˜ ๋ฉ”์„œ๋“œ 1. int → Integer Integer num = Integer.valueOf(10); 2. Integer → int Integer num = 10; int num02 = num.intValue(); 3. String → Integer String str = "10"; Integer num = Integer.getInteger(str); 4. String → int String str = ..

Java 2021.06.27

Java ์ž๋ฐ” List<Integer> ๋ฆฌ์ŠคํŠธ๋ฅผ int[] ๋ฐฐ์—ด๋กœ ๋ฐ”๊พธ๊ธฐ

List ๋ฆฌ์ŠคํŠธ๋ฅผ int[] ๋ฐฐ์—ด๋กœ ๋ฐ”๊พธ๊ธฐ import java.util.*; import java.util.stream.Collectors; class Solution { public int[] solution(int[] progresses, int[] speeds) { List answer = new ArrayList(); ... return answer.stream().mapToInt(i->i).toArray(); } } stream.Collectors๋ฅผ import ํ•ด์ฃผ์–ด์•ผ ํ•œ๋‹ค. ๊ทธ๋Ÿฌ๋ฉด, mapToInt ๋ฉ”์†Œ๋“œ๋ฅผ ํ†ตํ•ด ๋ฐ์ดํ„ฐ ํƒ€์ž…์ด Integer์˜€๋˜ ๋ฆฌ์ŠคํŠธ๋ฅผ int[] ๋ฐฐ์—ด๋กœ ๋ฐ”๊ฟ€ ์ˆ˜ ์žˆ๋‹ค! ๐Ÿ‘๐Ÿ‘

Java 2021.06.08

๊ฐ์ฒด ์ง€ํ–ฅ ์ƒํ™œ ์ฒด์กฐ ์›์น™

๐Ÿ™‹‍โ™€๏ธ ๊ฐ์ฒด ์ง€ํ–ฅ ์ƒํ™œ ์ฒด์กฐ ์›์น™ ๊ฐ์ฒด ์ง€ํ–ฅ ํ”„๋กœ๊ทธ๋ž˜๋ฐ์„ ์ž˜ํ•˜๊ธฐ ์œ„ํ•œ 9๊ฐ€์ง€ ์›์น™. ํ•œ ๋ฉ”์„œ๋“œ์— ์˜ค์ง ํ•œ ๋‹จ๊ณ„์˜ ๋“ค์—ฌ ์“ฐ๊ธฐ๋งŒ ํ•œ๋‹ค. else ์˜ˆ์•ฝ์–ด๋ฅผ ์“ฐ์ง€ ์•Š๋Š”๋‹ค. ๋ชจ๋“  ์›์‹œ ๊ฐ’๊ณผ ๋ฌธ์ž์—ด์„ ํฌ์žฅํ•œ๋‹ค. ํ•œ ์ค„์— ์ ์„ ํ•˜๋‚˜๋งŒ ์ฐ๋Š”๋‹ค. ์ค„์—ฌ ์“ฐ์ง€ ์•Š๋Š”๋‹ค(์ถ•์•ฝ ๊ธˆ์ง€). ๋ชจ๋“  ์—”ํ‹ฐํ‹ฐ๋ฅผ ์ž‘๊ฒŒ ์œ ์ง€ํ•œ๋‹ค. 3๊ฐœ ์ด์ƒ์˜ ์ธ์Šคํ„ด์Šค ๋ณ€์ˆ˜๋ฅผ ๊ฐ€์ง„ ํด๋ž˜์Šค๋ฅผ ์“ฐ์ง€ ์•Š๋Š”๋‹ค. ์ผ๊ธ‰ ์ปฌ๋ ‰์…˜์„ ์“ด๋‹ค. getter/setter/ํ”„๋กœํผํ‹ฐ๋ฅผ ์“ฐ์ง€ ์•Š๋Š”๋‹ค. ์ถœ์ฒ˜ ์†ŒํŠธ์›์Šค ์•ค์†”๋Ÿฌ์ง€

Java 2021.05.31

Java split()๊ณผ StringTokenizer ์ฐจ์ด

library1008.tistory.com/16 ๋ฌธ์ž์—ด ๋ถ„๋ฆฌ - split() ์™€ StringTokenizer ์˜ ์ฐจ์ด์  ๋ฌธ์ž์—ด์„ ์›ํ•˜๋Š” ๊ตฌ๋ถ„์ž(delimiter)๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋ถ„๋ฆฌํ•˜๊ณ  ์‹ถ์„ ๋•Œ StringTokenizer ์™€ String ๋ฉ”์†Œ๋“œ split() ๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๊ฐ™์ง€๋งŒ ๋‹ค๋ฅธ ๋‘ ๊ฐ€์ง€ ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด์„œ ์•Œ์•„๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค. (์˜ˆ์ œ์— library1008.tistory.com ์ •๋ง ์ •๋ฆฌ๋ฅผ ์ž˜ํ•ด๋†“์œผ์…จ๋‹ค!! ๐Ÿ‘๐Ÿ‘

Java 2021.01.15

Java ์ž๋ฐ” String ๋น„๊ต ๋ฉ”์†Œ๋“œ equals์™€ compareTo

๋งจ๋‚  ๊นŒ๋จน์–ด์„œ ๋ธ”๋กœ๊ทธ์— ์ •๋ฆฌํ•ด๋†“๊ธฐ เน‘โ—•โ€ฟโ—•เน‘ 1. equals str1.equals(str2) boolean ํƒ€์ž…์œผ๋กœ ๋ฆฌํ„ด ๋‘ ๋ฌธ์ž์—ด์ด ๊ฐ™์œผ๋ฉด true, ๋‹ค๋ฅด๋ฉด false ๋ฆฌํ„ด 2. compareTo str1.compareTo(str2) integer ํƒ€์ž…์œผ๋กœ ๋ฆฌํ„ด ์‚ฌ์ „์‹ ์ˆœ์„œ๋กœ ๊ฒ€์‚ฌ str1์ด ๋น ๋ฅด๋ฉด ์Œ์ˆ˜, ๊ฐ™์œผ๋ฉด 0, ํฌ๋ฉด ์–‘์ˆ˜ ๋ฆฌํ„ด Tip) str1๊ณผ str2 ์‚ฌ์ด์— ๋ถ€๋“ฑํ˜ธ๊ฐ€ ์žˆ๋‹ค๊ณ  ์ƒ๊ฐํ•˜๊ณ  ๊ทธ๊ฑธ ๊ทธ๋Œ€๋กœ 0์— ๋Œ€์ž…!! 3. compareToIgnoreCase ๋Œ€์†Œ๋ฌธ์ž ๊ตฌ๋ถ„์—†์ด ๋น„๊ต

Java 2020.07.17