Spring/JAVA

๋ฐ์ดํ„ฐ (์ˆซ์ž, ๋ฌธ์ž์—ด) ๋‹ค๋ฃจ๊ธฐ

alsruds 2023. 9. 20. 21:16
๐Ÿฃ์ƒํ™œ์ฝ”๋”ฉ ๊ฐ•์˜๐Ÿฃ

JAVA1 - 6.1. ๋ฐ์ดํ„ฐ์™€ ์—ฐ์‚ฐ
https://www.youtube.com/watch?v=WWAicgDYBDg&list=PLuHgQVnccGMAIluRRVsC1e79ri-dwnBmR&index=14
JAVA1 - 6.2. ๋ฐ์ดํ„ฐ ํƒ€์ž…
https://www.youtube.com/watch?v=_D13-YBz4qk&list=PLuHgQVnccGMAIluRRVsC1e79ri-dwnBmR&index=15
JAVA1 - 6.3. ์ˆซ์ž์™€ ์—ฐ์‚ฐ
https://www.youtube.com/watch?v=3atGGWQYaiU&list=PLuHgQVnccGMAIluRRVsC1e79ri-dwnBmR&index=16
JAVA1 - 6.4. ๋ฌธ์ž์—ด์˜ ํ‘œํ˜„
https://www.youtube.com/watch?v=DCa3qo8Pm6E&list=PLuHgQVnccGMAIluRRVsC1e79ri-dwnBmR&index=17
JAVA1 - 6.5. ๋ฌธ์ž์—ด ๋‹ค๋ฃจ๊ธฐ
https://www.youtube.com/watch?v=y20Fhlseh4w&list=PLuHgQVnccGMAIluRRVsC1e79ri-dwnBmR&index=18

 

โœ”๏ธ ๋ฐ์ดํ„ฐ ํƒ€์ž… ๋ณ„ ๋ฐ์ดํ„ฐ ์ฒ˜๋ฆฌ ๋ฐฉ์‹์ด ๋‹ค๋ฅด๋‹ค

  1. ์–ด๋–ค ์ข…๋ฅ˜์˜ ๋ฐ์ดํ„ฐ ํƒ€์ž…์ด ์กด์žฌํ•˜๋Š”์ง€ ์•Œ์•„๋ณด๊ธฐ
  2. ๋ฐ์ดํ„ฐ ํƒ€์ž… ๋ณ„๋กœ ์–ด๋–ค ์—ฐ์‚ฐ ๋ฐฉ๋ฒ•์ด ์กด์žฌํ•˜๋Š”์ง€ ์•Œ์•„๋ณด๊ธฐ

 

์ˆซ์ž

โœจ Operator (์—ฐ์‚ฐ์ž) 

System.out.println(10 + 2); // 12
System.out.println(10 - 2); // 8
System.out.println(10 * 2); // 20
System.out.println(10 / 2); // 5

 

โœจ Math class

System.out.println(Math.PI); // 3.141592653589793
System.out.println(Math.floor(Math.PI)); // 3.0
System.out.println(Math.ceil(Math.PI)); // 4.0

· Math.PI : ํŒŒ์ด ์ƒ์ˆ˜

· Math.floor() : ์ˆซ์ž ๋‚ด๋ฆผ

· Math.ceil() : ์ˆซ์ž ์˜ฌ๋ฆผ

 

๋ฌธ์ž์—ด

โœจ Character vs. String

System.out.println('H'); // Character
System.out.println("Hello World"); // String : Character ๋ชจ์Œ

· ๋ฌธ์ž ≠ ๋ฌธ์ž์—ด

 

โœจ ์ค„๋ฐ”๊พธ๊ธฐ &  ํŠน์ˆ˜๋ฌธ์ž

// ์ค„๋ฐ”๊ฟˆ (new line)
System.out.println("Hello\nWorld");
// ํŠน์ˆ˜๋ฌธ์ž (escape)
System.out.println("Hello \"World\"");

์ถœ๋ ฅ ๋ฐฉ์‹

 

โœจ length() & replace()

System.out.println("Hello World".length()); // 11
System.out.println("Hello [name]".replace("[name]", "alsrud")); // Hello alsrud

· length() : ๋ฌธ์ž์—ด ๊ธธ์ด

· replace() : ๋ฌธ์ž์—ด ์น˜ํ™˜