Java & Spring
[์๋ฐ/ํ์ด์ฌ ์๊ณ ๋ฆฌ์ฆ] ์์ ์๊ณ ๋ฆฌ์ฆ
int[] scores = { 100, 33, 44, 55, 66, 77, 88 }; 100 1๋ฑ 33 7๋ฑ 44 6๋ฑ 55 5๋ฑ 66 4๋ฑ 77 3๋ฑ 88 2๋ฑ ์๋ฐ public class Hello { public static void main(String[] args) { // [1] Input : ์๋ฃ๊ตฌ์กฐ int[] scores = { 100, 33, 44, 55, 66, 77, 88 }; int[] rankings = new int[scores.length]; // [2] Process : RANK for (int i = 0; i < scores.length; i++) { rankings[i] = 1; //1๋ฑ์ผ๋ก ์ด๊ธฐํ, ์์ ๋ฐฐ์ด์ ๋งค ํ์ ๋ง๋ค 1๋ฑ์ผ๋ก ์ด๊ธฐํ for (int j = 0; j..
![[์คํ๋ง๋ถํธ] STS ์ค์น : Spring Tool Sulte 4](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FcqN0z4%2FbtrTRFCeAmg%2FkoXkkMjWhrlhWMvK3ePTD0%2Fimg.png)
[์คํ๋ง๋ถํธ] STS ์ค์น : Spring Tool Sulte 4
STS๋ ์คํ๋ง๋ถํธ ์ ์ฉ ๊ฐ๋ฐ ํด์ด๋ค. ์ฒ์ ์คํ๋ง๋ถํธ ๊ฐ๋ฐ์ ์ ํ ๋ ๋ง์ด ๊ถ์ฅ๋๋ ํด์ด๋ค. ์ค์ ๋ ๋งค์ฐ ์ฝ๊ณ ํธ๋ฆฌํ๋ค๋ ์ฅ์ ์ด ์๋ค. ํนํ ์์กด์ฑ ๊ด๋ฆฌ๊ฐ ๋งค์ฐ ํธ๋ฆฌํ๊ณ ๊ฑฐ์ ์ค์ ์ ํ๋ ๊ฒ ์์ ์ ๋~! ํฐ์บฃ๊ณผ ๊ฐ์ ์๋ฒ๋ ๋ค ๋ด์ฅ๋์ด ์์ผ๋ฏ๋ก ๋ฐ๋ก ์ค์นํ ํ์๊ฐ ์๋ค ^^ * ์ฐธ๊ณ ๋ก, ์๋ฐ๊ฐ ์ด๋ฏธ ์ค์น๋ ์ํ์ฌ์ผ ํด๋น ํฌ์คํ ์ ์ ๋ฐ๋ผํ์ค ์ ์์ต๋๋ค. * ์๋ ๋งํฌ๋ก ๋ค์ด๊ฐ์ Spring Tools 4 is the next generation of Spring tooling Largely rebuilt from scratch, Spring Tools 4 provides world-class support for developing Spring-based enterprise applications,..
[์๋ฐ/ํ์ด์ฌ ์๊ณ ๋ฆฌ์ฆ] ๊ทผ์ฟ๊ฐ ์๊ณ ๋ฆฌ์ฆ
TIP ์ฐจ์ด๊ฐ์ ์ ๋๊ฐ์ ์ต์๊ฐ ์๊ณ ๋ฆฌ์ฆ์ ์ ์ฉํด์ฃผ๋ฉด ๋๋ค. ์ฐจ์ด๊ฐ์ ์ ๋๊ฐ์ ๋ด์์ค min ๋ณ์์ ๊ฒฐ๊ณผ๊ฐ ๋ด๊ธธ near ๋ณ์๊ฐ ํ์ํ๋ค๋ ๊ฒ์ด ์ค์ ํฌ์ธํธ์ธ ์๊ณ ๋ฆฌ์ฆ! ์๋ฐ import java.util.Arrays; public class App { public static void main(String[] args) throws Exception { //[1] Initialize int min = Integer.MAX_VALUE; //[2] Input int [] numbers = {23,56,65,2,2,3,3}; int target = 25; int near = 0; //[3] Process : MAX for(int x : numbers) { if(Math.abs(target - x) < min..
[์๋ฐ/ํ์ด์ฌ ์๊ณ ๋ฆฌ์ฆ] ์ต๋๊ฐ ์๊ณ ๋ฆฌ์ฆ
๋ก์ง ํ๋ฆ //[1] Initialize //[2] Input //[3] Process : MAX //[4] Output ์๋ฐ public class App { public static void main(String[] args) throws Exception { //[1] Initialize int max = Integer.MIN_VALUE; //[2] Input int[] nums = {3,56,65,2,2,3,3}; //[3] Process : MAX for(int x : nums) { if(x > max){ max = x; } } //[4] Output System.out.println(max); } } ํ์ด์ฌ nums = [3,56,65,2,2,3,3] max = 0 for x in range(..
[JAVA] ์๋ฐ์ Array : Compare, fill, sort
1. ํฅ์๋ loop public class App { public static void main(String[] args) throws Exception { //[1] Input : n๋ช ์ ๊ตญ์ด ์ ์ int[] scores = {100, 75, 3 ,5 ,3, 22, 34}; int sum = 0; //[2] Process for (int i = 0; i < scores.length; i++) { sum += scores[i]; } //[3] Output System.out.println(sum); int sum1 = 0; for (int x : scores) { sum1 += x; } System.out.println(sum1); } } int[] scores = {100, 75, 3 ,5 ,3, 2..
[์๋ฐ/ํ์ด์ฌ ์๊ณ ๋ฆฌ์ฆ] ํฉ๊ณ ์๊ณ ๋ฆฌ์ฆ
์๋ฐ public class App { public static void main(String[] args) throws Exception { //[1] Input : n๋ช ์ ๊ตญ์ด ์ ์ int[] scores = {100, 75, 3 ,5 ,3, 22, 34}; int sum = 0; //[2] Process for (int i = 0; i < scores.length; i++) { sum += scores[i]; } //[3] Output System.out.println(sum); } } ํ์ด์ฌ my_list = [100, 75, 3,5,3,22,34] sum = 0 for x in range(len(my_list)): sum = sum + my_list[x] print(sum) ํํฐ๋ง์ ์๋์ ๊ฐ์ด..
[์๋ฐ/ํ์ด์ฌ ์๊ณ ๋ฆฌ์ฆ] ํ์ต ์์
์๋ฐ๋ ํ์ด์ฌ์ ๊ด์ฌ์ด ์๊ฒผ๋๋ฐ, ์ ์ธ์ด๋ฅผ ๊ฐ์ฅ ๋นจ๋ฆฌ ํก์ํ๋ ๋ฐฉ๋ฒ์ ๊ทธ ์ธ์ด๋ก ์๊ณ ๋ฆฌ์ฆ์ ์ง๋ ๊ฒ์ด๋ผ๋ ์๊ฐ์ ์๋ฐ/ํ์ด์ฌ์ผ๋ก ์๊ณ ๋ฆฌ์ฆ์ ๋๋๋ ค๋ณด๋ฉด์ ์ฒด๋ํ ์๊ฐ์ด๋ค. ์๋ฐ๋ฅผ ๊ธฐ์ค์ผ๋ก ์๊ณ ๋ฆฌ์ฆ์ ์ง๊ณ ํ์ด์ฌ์ผ๋ก ๋๊ฐ์ ๋ก์ง์ ๋๋ค๊ฒจ๋ณด๋ ์์ผ๋ก ์งํํ ์์ ์ด๋ค. (๋ฑ๋ฑํ ์๋ฐ๋ก ์งค ์ ์๋ ๋ก์ง์ด๋ฉด ๋น๋จ๋ฑ๊ฐ์ ํ์ด์ฌ์ ๋ฅ์ด ์งค ์ ์๋๋ฐ ์ญ์ผ๋ก๋ ์ฑ๋ฆฝํ์ง ์์ ์ ์๊ธฐ ๋๋ฌธ^_^;) ์๊ณ ๋ฆฌ์ฆ์ ๋ฌธ์ ํด๊ฒฐ๋ฅ๋ ฅ์ด๋ค. - ํฉ๊ณ ์๊ณ ๋ฆฌ์ฆ : tnduf - ๊ฐ์ ์๊ณ ๋ฆฌ์ฆ - ํ๊ท ์๊ณ ๋ฆฌ์ฆ - ์ต๋๊ฐ ์๊ณ ๋ฆฌ์ฆ : max - ์ต์๊ฐ ์๊ณ ๋ฆฌ์ฆ : min - ๊ทผ์ฟ๊ฐ ์๊ณ ๋ฆฌ์ฆ : ๊ฐ๊น์ด ๊ฐ - ์์ ์๊ณ ๋ฆฌ์ฆ : ๋ฑ์ - ์ ๋ ฌ ์๊ณ ๋ฆฌ์ฆ : ์ ํ ์ ๋ ฌ, ๋ฒ๋ธ ์ํธ, ํต ์ํธ ๋ฑ - ๊ฒ์ ์๊ณ ๋ฆฌ์ฆ : ์์ฐจ๊ฒ์, ์ด์ง๊ฒ์(์ด๋ถ..
![[Java] ์ธํฐํ์ด์ค](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2F2DI4y%2FbtrTDZlMWXx%2FVDlwVhTp25FIcBmykYkRFK%2Fimg.png)
[Java] ์ธํฐํ์ด์ค
ํด๋์ค ๋์ ์ธํฐํ์ด์ค ํค์๋๋ฅผ ์ฌ์ฉํ๋ค. ์ธํฐํ์ด์ค์์๋ ์ ์ธ์ ์ ๊ณตํ๋ ๊ฒ์ด์ง, ์ ์๋ฅผ ๋ด๋ฆฌ๋ ๊ฒ์ด ์๋๋ค. public interface GamingConsole { public void up(); public void down(); public void left(); public void right(); } ํด๋น ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ ํด๋์ค๋ฅผ ํ๋ ๋ง๋ค์ด์ค๋ค. public class MarioGame implements GamingConsole { @Override public void up() { System.out.println("Jump!"); } @Override public void down() { System.out.println("Goes into a hole!"); } @Overrid..
![[Java] ์๋ฐ List ์ธํฐํ์ด์ค ๊ตฌํ ArrayList vs LinkedList](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FdTXuoE%2FbtrS9rrKypg%2F0Mp0yOhIKPyBeSTGjWkwo1%2Fimg.png)
[Java] ์๋ฐ List ์ธํฐํ์ด์ค ๊ตฌํ ArrayList vs LinkedList
์ ํฌ์คํ ์ ์ด์ด์ ์์ฑํฉ๋๋ค. import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import java.util.Vector; public class Hello { public static void main(String[] args) { List words = List.of("Jisoo", "Lisa", "Jenny", "Rose"); List wordsArrayList = new ArrayList(words); wordsArrayList.add("GD"); System.out.println(wordsArrayList); // [Jisoo, Lisa, Jenny, Rose, GD] System.out.printl..
![[Java] ์๋ฐ List.of()๋ก ๋ง๋ ๋ถ๋ณ ๋ฆฌ์คํธ๋ฅผ ๊ฐ๋ณ ๋ฆฌ์คํธ๋ก ๋ฐ๊พธ๊ธฐ](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2Fb6JzpY%2FbtrTaCmdRX2%2FohbsYqOEX73JNaV9TkX1d0%2Fimg.png)
[Java] ์๋ฐ List.of()๋ก ๋ง๋ ๋ถ๋ณ ๋ฆฌ์คํธ๋ฅผ ๊ฐ๋ณ ๋ฆฌ์คํธ๋ก ๋ฐ๊พธ๊ธฐ
์ด๋ฒ ํฌ์คํ ์์๋ List.of()๋ก ๋ง๋ ๋ถ๋ณ ๋ฆฌ์คํธ(๋ด๋ถ ์ ๋ณด ๋ฐ๊ฟ ์ ์์)๋ฅผ ํ์ตํด๋ณด๊ณ , ์ด๋ฅผ ํตํด ๊ฐ๋ณ ๋ฆฌ์คํธ(๋ด๋ถ์ ๋ณด ๋ฐ๊ฟ ์ ์์)๋ฅผ ๋ง๋๋ ๋ฐฉ๋ฒ๊น์ง ์์๋ณธ๋ค. Collections - List - Set - Queue - Map ์๋ฐ๋ฅผ ๊ณต๋ถํ ๋ ํ๋ ์ต์ ๋ฒ์ + ํค์๋ ๊ตฌ๊ธ๋งํ์ฌ ์ ์ผ ์์ ๋์ค๋ ์ค๋ผํด ํฌํผ ์ผํฐ ๋ฌธ์๋ฅผ ์ด์ฌํ ์ฝ์ ๊ฒ. List ์ ์ https://docs.oracle.com/javase/9/docs/api/java/util/List.html ์ ๋ ฌ๋ ์ปฌ๋ ์ ( sequence๋ผ๊ณ ๋ ํจ ). ์ด ์ธํฐํ์ด์ค์ ์ฌ์ฉ์๋ ๋ชฉ๋ก์์ ๊ฐ ์์๊ฐ ์ฝ์ ๋๋ ์์น๋ฅผ ์ ํํ๊ฒ ์ ์ดํ ์ ์์ต๋๋ค. ์ฌ์ฉ์๋ ์ ์ ์ธ๋ฑ์ค(๋ชฉ๋ก์ ์์น)๋ก ์์์ ์ก์ธ์คํ๊ณ ๋ชฉ๋ก์ ์์๋ฅผ ๊ฒ์ํ ์ ์์ต๋๋ค...