Notice
Recent Posts
Recent Comments
ยซ   2024/12   ยป
์ผ ์›” ํ™” ์ˆ˜ ๋ชฉ ๊ธˆ ํ† 
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
Archives
Today
In Total
๊ด€๋ฆฌ ๋ฉ”๋‰ด

A Joyful AI Research Journey๐ŸŒณ๐Ÿ˜Š

[22] 230130 Java Ch. 2 ๋ณ€์ˆ˜์™€ ํƒ€์ž…: 1. ๋ณ€์ˆ˜, 2. ๊ธฐ๋ณธ ํƒ€์ž… [K-๋””์ง€ํ„ธ ํŠธ๋ ˆ์ด๋‹ 22์ผ] ๋ณธ๋ฌธ

๐ŸŒณBootcamp Revision 2023โœจ/Spring Framework, Java

[22] 230130 Java Ch. 2 ๋ณ€์ˆ˜์™€ ํƒ€์ž…: 1. ๋ณ€์ˆ˜, 2. ๊ธฐ๋ณธ ํƒ€์ž… [K-๋””์ง€ํ„ธ ํŠธ๋ ˆ์ด๋‹ 22์ผ]

yjyuwisely 2023. 1. 30. 12:49

230130 Mon 22nd class

Ch. 2 ๋ณ€์ˆ˜์™€ ํƒ€์ž…
์ง„๋„: p. 59 ~ (๊ต์žฌ: ํ˜ผ์ž ๊ณต๋ถ€ํ•˜๋Š” ์ž๋ฐ”, ์ €์ž: ์‹ ์šฉ๊ถŒ)

 

ํ˜ผ์ž ๊ณต๋ถ€ํ•˜๋Š” ์ž๋ฐ” | ์‹ ์šฉ๊ถŒ - ๊ต๋ณด๋ฌธ๊ณ 

ํ˜ผ์ž ๊ณต๋ถ€ํ•˜๋Š” ์ž๋ฐ” | ํ˜ผ์ž ํ•ด๋„ ์ถฉ๋ถ„ํ•˜๋‹ค! 1:1 ๊ณผ์™ธํ•˜๋“ฏ ๋ฐฐ์šฐ๋Š” ์ž๋ฐ” ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์ž์Šต์„œ (JAVA 8 &11 ์ง€์›) ์ด ์ฑ…์€ ๋…ํ•™์œผ๋กœ ์ž๋ฐ”๋ฅผ ๋ฐฐ์šฐ๋Š” ์ž…๋ฌธ์ž๊ฐ€ ‘๊ผญ ํ•„์š”ํ•œ ๋‚ด์šฉ์„ ์ œ๋Œ€๋กœ’ ํ•™์Šตํ•  ์ˆ˜ ์žˆ๋„

product.kyobobook.co.kr

์˜ค๋Š˜ ๋ฐฐ์šด ๊ฒƒ ์ค‘ ๊ธฐ์–ตํ•  ๊ฒƒ์„ ์ •๋ฆฌํ–ˆ๋‹ค. 


์ง€๋‚œ ์ˆ˜์—… ๋•Œ ๋ฐฐ์šด ๊ฒƒ ์ค‘ ๋‹ค์‹œ ๊ธฐ์–ตํ•  ๊ฒƒ

2023.01.10 - [1. Revision 2023/Javascript] - [10] 230110 Ch. 8 ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ๊ธฐ์ดˆ(2): ์ˆซ์ž์™€ ๋ฌธ์ž์—ด ์‚ฌ์ด์˜ ๋ณ€ํ™˜

parseInt()

๋ฌธ์ž์—ด์„ ์ˆซ์ž๋กœ ๋ณ€ํ™˜ํ•œ๋‹ค.

parse:  to divide (a sentence) into grammatical parts and identify the parts and their relations to each other.
[Computing] analyse (a string or text) into logical syntactic components
syntactic: ๊ตฌ๋ฌธ๋ก ์˜(์–ธ์–ด ๋‹จ์–ด ๊ฒฐํ•ฉ์œผ๋กœ ์ด๋ฃจ์–ด์ง€๋Š” ๋ฌธ์žฅ(ๆ–‡็ซ )์˜ ๊ตฌ์กฐ๋‚˜ ๊ตฌ๋ฌธ(ๆง‹ๆ–‡) ์š”์†Œ๋ฅผ ๋ถ„์„ํ•จ์œผ๋กœ์จ, ๊ฐ ๋ฌธ์žฅ ์„ฑ๋ถ„์ด ๊ตฌ์„ฑ๋˜๋Š” ๊ทœ์น™์„ ์—ฐ๊ตฌํ•˜๋Š” ๋ถ„์•ผ.)


Ch. 2 ๋ณ€์ˆ˜์™€ ํƒ€์ž… p. 48

์ฑ…์˜ ๋ชฉ์ฐจ
02-1 ๋ณ€์ˆ˜
02-2 ๊ธฐ๋ณธ ํƒ€์ž…
02-3 ํƒ€์ž… ๋ณ€ํ™˜
02-4 ๋ณ€์ˆ˜์™€ ์‹œ์Šคํ…œ ์ž…์ถœ๋ ฅ

2.1 ๋ณ€์ˆ˜ (Variable)

๋ณ€์ˆ˜(Variable): ๊ฐ’์„ ์ €์žฅํ•  ์ˆ˜ ์žˆ๋Š” ๋ฉ”๋ชจ๋ฆฌ์˜ ํŠน์ • ๋ฒˆ์ง€์— ๋ถ™์ด๋Š” ์ด๋ฆ„

์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ์ฒ˜๋Ÿผ ์ •์ˆ˜ ๋„ฃ๊ณ  ๋ฌธ์ž ๋„ฃ๋Š” ๊ฑฐ ์•ˆ ๋œ๋‹ค.
var a; 

var: ๋ณ€์ˆ˜์ž„์„ ์•Œ๋ฆฌ๋Š” ๊ฒƒ. ํƒ€์ž…์ด ์•„๋‹ˆ๋‹ค.


1) ๋ณ€์ˆ˜ ์„ ์–ธ

๋ณ€์ˆ˜ ์„ ์–ธ: ๋ณ€์ˆ˜์— ์–ด๋–ค ํƒ€์ž…(type)์˜ ๋ฐ์ดํ„ฐ๋ฅผ ์ €์žฅํ• ์ง€, ๋ณ€์ˆ˜ ์ด๋ฆ„์ด ๋ฌด์—‡์ธ์ง€ ๊ฒฐ์ •ํ•˜๋Š” ๊ฒƒ์ด๋‹ค.

ํƒ€์ž…(type) = ํ˜•, ์ž๋ฃŒํ˜•
ex) int, double

int age;
double value;

int: ์ •์ˆ˜(์†Œ์ˆ˜์  ์—†์Œ)๋ฅผ ์ €์žฅํ•  ์ˆ˜ ์žˆ๋Š” age ๋ณ€์ˆ˜ ์„ ์–ธ
ex) ์†Œ์ˆ˜์  ์žˆ๋Š” ์ˆซ์ž๋ฅผ ๋„ฃ์œผ๋ฉด ์†Œ์ˆ˜์  ์ˆซ์ž๋Š” ๋‹ค ์ž˜๋ฆฐ๋‹ค. 

double
: ์‹ค์ˆ˜(์†Œ์ˆ˜์  ์žˆ๋Š” ์ˆซ์ž)๋ฅผ ์ €์žฅํ•  ์ˆ˜ ์žˆ๋Š” value ๋ณ€์ˆ˜ ์„ ์–ธ
ex) 3์ด ์•„๋‹Œ 3.0์œผ๋กœ ์ €์žฅ๋œ๋‹ค.

int x;
int y;
int z;

์€ ์•„๋ž˜์™€ ๋™์ผํ•˜๋‹ค. ๊ฐ™์€ ํƒ€์ž…์ด๋ฉด ,๋ฅผ ์ด์šฉํ•ด์„œ ํ•œ๊บผ๋ฒˆ์— ์„ ์–ธํ•  ์ˆ˜ ์žˆ๋‹ค.

int x, y, z;

 

๋ณ€์ˆ˜ ์ด๋ฆ„ ๋ช…๋ช… ๊ทœ์น™์„ ๋”ฐ๋ผ์•ผ ํ•œ๋‹ค. 

์ž‘์„ฑ ๊ทœ์น™ ์˜ˆ
์ฒซ ๋ฒˆ์งธ ๊ธ€์ž๋Š” ๋ฌธ์ž์ด๊ฑฐ๋‚˜ '$', '_'์ด์–ด์•ผ ํ•˜๊ณ  ์ˆซ์ž๋กœ ์‹œ์ž‘ํ•  ์ˆ˜ ์—†๋‹ค. ๊ฐ€๋Šฅ: price, $price, _companyName
๋ถˆ๊ฐ€๋Šฅ: 1v, @speed, $#value
์˜์–ด ๋Œ€์†Œ๋ฌธ์ž๋ฅผ ๊ตฌ๋ถ„ํ•œ๋‹ค. (ํ•„์ˆ˜)  firstname๊ณผ firstName์€ ๋‹ค๋ฅธ ๋ณ€์ˆ˜์ด๋‹ค.
age์™€ Age๋Š” ๋‹ค๋ฅธ ๋ณ€์ˆ˜์ด๋‹ค. 
์ฒซ ๋ฌธ์ž๋Š” ์˜์–ด ์†Œ๋ฌธ์ž๋กœ ์‹œ์ž‘ํ•˜๋˜, ๋‹ค๋ฅธ ๋‹จ์–ด๊ฐ€ ๋ถ™์„ ๊ฒฝ์šฐ ์ฒซ ๋ฌธ์ž๋ฅผ ๋Œ€๋ฌธ์ž๋กœ ํ•œ๋‹ค.(๊ด€๋ก€) 
ํด๋ž˜์Šค ์ด๋ฆ„์ด ๋Œ€๋ฌธ์ž์ด๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค. 
maxSpeed, firstName, carBodyColor
๋ฌธ์ž ์ˆ˜(๊ธธ์ด)์˜ ์ œํ•œ์€ ์—†๋‹ค.  
์ž๋ฐ” ์˜ˆ์•ฝ์–ด๋Š” ์‚ฌ์šฉํ•  ์ˆ˜ ์—†๋‹ค. (ํ•„์ˆ˜)   

 

์˜ˆ์•ฝ์–ด: ์ด๋ฏธ ํ•ด๋‹น ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด์—์„œ ์˜๋ฏธ๋ฅผ ๊ฐ–๊ณ  ์‚ฌ์šฉ๋˜๊ณ  ์žˆ๋Š” ๋‹จ์–ด
๋ณ€์ˆ˜ ์ด๋ฆ„์œผ๋กœ ์‚ฌ์šฉํ•  ์ˆ˜ ์—†๋‹ค. ๋ณ€์ˆ˜ ์ด๋ฆ„์„ ์„ ์–ธํ•˜๋ฉด ์ปดํŒŒ์ผ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•œ๋‹ค.

๋ถ„๋ฅ˜ ์˜ˆ์•ฝ์–ด
๊ธฐ๋ณธ ํƒ€์ž… boolean, byte, char, short, int, long, float, double

ex) Int(๋Œ€๋ฌธ์ž๋กœ ์‹œ์ž‘)๋Š” ๋œ๋‹ค. 
์ ‘๊ทผ ์ œํ•œ์ž private, protected, public
ํด๋ž˜์Šค์™€ ๊ด€๋ จ class, abstract, interface, extends, implements, enum

enum์€ enumeration์ด๋ผ๋Š” ์…ˆ, ๊ณ„์‚ฐ, ์—ด๊ฑฐ, ๋ชฉ๋ก์ด๋ผ๋Š” ์˜์–ด๋‹จ์–ด์˜ ์•ž๋ถ€๋ถ„๋งŒ ๋”ฐ์„œ ๋งŒ๋“  ์˜ˆ์•ฝ์–ด
enumeration: the action of mentioning a number of things one by one
๊ฐ์ฒด์™€ ๊ด€๋ จ new, instanceof, this, super, null
๋ฉ”์„œ๋“œ์™€ ๊ด€๋ จ void, return
์ œ์–ด๋ฌธ๊ณผ ๊ด€๋ จ if, else, switch, case, default, for, do, while, break, continue
๋…ผ๋ฆฌ๊ฐ’ true, false
์˜ˆ์™ธ์ฒ˜๋ฆฌ์™€ ๊ด€๋ จ try, catch, finally, throw, throws
๊ธฐํƒ€ package, import, synchronized, final, static

 

2) ๊ฐ’ ์ €์žฅ

๋Œ€์ž… ์—ฐ์‚ฐ์ž(=)๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค. ์˜ค๋ฅธ์ชฝ์˜ ๊ฐ’์„ ์™ผ์ชฝ์˜ ๋ณ€์ˆ˜์— ์ €์žฅํ•œ๋‹ค.
ํƒ€์ž… ๋ณ€์ˆ˜๋ช… = ๊ฐ’;

int a = 10;
int score; //score ๋ณ€์ˆ˜ ์„ ์–ธ
score = 90; //์„ ์–ธ๋œ score ๋ณ€์ˆ˜์— ๊ฐ’ 90 ์ €์žฅ: 90 -> score

int score = 90; //score ๋ณ€์ˆ˜๋ฅผ ์„ ์–ธํ•จ๊ณผ ๋™์‹œ์— ๊ฐ’ 90์„ ์ €์žฅํ•œ๋‹ค.

๋ณ€์ˆ˜ ์ดˆ๊ธฐํ™”: ๋ณ€์ˆ˜์— ์ตœ์ดˆ๋กœ ๊ฐ’์ด ์ €์žฅ๋  ๋•Œ ๋ณ€์ˆ˜๊ฐ€ ์ƒ์„ฑ๋œ๋‹ค. 
์ดˆ๊ธฐ๊ฐ’: ์‚ฌ์šฉ๋œ ๊ฐ’
์œ„์˜ ์˜ˆ์ œ์—์„œ ์ดˆ๊ธฐ๊ฐ’: 90

3) ๋ณ€์ˆ˜ ์‚ฌ์šฉ

์˜ˆ์ œ) 
println์„ ์จ์„œ ์—”ํ„ฐ ํšจ๊ณผ๊ฐ€ ์žˆ๋‹ค. 

public class VariableUseExample {
	public static void main(String[] args) {
		int hour = 3;
		int minute = 5;
		System.out.println(hour+"์‹œ๊ฐ„ "+minute+"๋ถ„");
		int totalMinute=(hour*60)+minute;
		System.out.println("์ด "+totalMinute+"๋ถ„");
	}
}

๊ฒฐ๊ณผ)
3์‹œ๊ฐ„ 5๋ถ„
์ด 185๋ถ„

๊ฐ’ ๋ฐ”๊ฟ€ ๋•Œ int temp ์“ด๋‹ค.
์˜ˆ์ œ)

	public static void main(String[] args) {
		int x = 3; 
		int y = 5;
		System.out.println("x: "+x+", y:"+y);
		
		int temp = x; // x๊ฐ’์„ temp์— ์ €์žฅ (3์„ temp๋ณ€์ˆ˜์— ์ €์žฅ)
		x = y; //y๊ฐ’์„ x์— ์ €์žฅ(5์„ x์— ์ €์žฅํ•˜๋ฏ€๋กœ x๋Š” 3->5)
		y = temp; //temp๊ฐ’์„ y์— ์ €์žฅ(3๋ฅผ y์— ์ €์žฅํ•˜๋ฏ€๋กœ y๋Š” 5->3)
		System.out.println("x: "+x+", y:"+y);
	}

 ๊ฒฐ๊ณผ)

x: 3, y:5
x: 5, y:3

 

4) ๋ณ€์ˆ˜ ์‚ฌ์šฉ ๋ฒ”์œ„ p. 55

๋กœ์ปฌ (์ง€์—ญ) ๋ณ€์ˆ˜(local variable): ๋ฉ”์„œ๋“œ ๋ธ”๋ก ๋‚ด์—์„œ ์„ ์–ธ๋œ ๋ณ€์ˆ˜
๋ฉ”์„œ๋“œ ์‹คํ–‰์ด ๋๋‚˜๋ฉด ๋ฉ”๋ชจ๋ฆฌ์—์„œ ์ž๋™์œผ๋กœ ์—†์–ด์ง„๋‹ค.

์ง€์—ญ๋ณ€์ˆ˜๋Š” ๋ฌด์กฐ๊ฑด ์ดˆ๊ธฐํ™”ํ•ด์ค˜์•ผ ํ•œ๋‹ค. (์ดˆ๊ธฐ๊ฐ’์„ ์ค€๋‹ค.)


์˜ˆ์ œ)

public class VariableScopeExample {

	public static void main(String[] args) {
		int v1 = 15;
		int v2 = 0;
		if (v1>10) {
			v2 = v1 - 10;
			//v1, v2 ์‚ฌ์šฉ ๊ฐ€๋Šฅ 
		}
		
		int v3 = v1 + v2 + 5;
		//v2๋ฅผ if ๋ธ”๋ก ์•ˆ์— ๋‘๋ฉด if ๋๋‚˜๊ณ  ์†Œ๋ฉธ์ด๋ฏ€๋กœ ์ปดํŒŒ์ผ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•œ๋‹ค. 
		System.out.println(v3);
		//25 = 15 + 5 + 5
	}
}

๊ฒฐ๊ณผ) ์ปดํŒŒ์ผ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•œ๋‹ค.

public class A{
	int var 4;//์ „์—ญ๋ณ€์ˆ˜
public static void main(String[] args){
int var1;

if(...){
	int var2;
    //var1, var2 ์‚ฌ์šฉ ๊ฐ€๋Šฅ
}
for(...){
	int var3;
    //var1, var3 ์‚ฌ์šฉ ๊ฐ€๋Šฅ
}
//var1 ์‚ฌ์šฉ ๊ฐ€๋Šฅ
}
}

 

๋ณ€์ˆ˜๋ฅผ ์„ ์–ธํ•  ๋•Œ ์ฃผ์˜ ์‚ฌํ•ญ

1. ๋ณ€์ˆ˜๊ฐ€ ์–ด๋–ค ๋ฒ”์œ„์—์„œ ์‚ฌ์šฉ๋  ๊ฒƒ์ธ์ง€๋ฅผ ์ƒ๊ฐํ•˜๊ณ , ์„ ์–ธ ์œ„์น˜๋ฅผ ๊ฒฐ์ •ํ•ด์•ผ ํ•œ๋‹ค.
2. ๋ฉ”์„œ๋“œ ๋ธ”๋ก ์ „์ฒด์—์„œ ์‚ฌ์šฉํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด ๋ฉ”์„œ๋“œ ๋ธ”๋ก ์ฒซ๋จธ๋ฆฌ์— ์„ ์–ธํ•œ๋‹ค.
๋ฉ”์„œ๋“œ ๋ธ”๋ก: public static void main(String[] args)
3. ํŠน์ • ๋ธ”๋ก ๋‚ด๋ถ€์—์„œ๋งŒ ์‚ฌ์šฉ๋œ๋‹ค๋ฉด ํ•ด๋‹น ๋ธ”๋ก ๋‚ด์—์„œ ์„ ์–ธํ•œ๋‹ค. 


๋งˆ๋ฌด๋ฆฌ p. 57

1) ๋ณ€์ˆ˜: ๊ฐ’์„ ์ €์žฅํ•  ์ˆ˜ ์žˆ๋Š” ๋ฉ”๋ชจ๋ฆฌ(ram) ๋ฒˆ์ง€์— ๋ถ™์ธ ์ด๋ฆ„. 
๋ณ€์ˆ˜๋ฅผ ํ†ตํ•ด ํ”„๋กœ๊ทธ๋žจ์€ ๋ฉ”๋ชจ๋ฆฌ ๋ฒˆ์ง€์— ๊ฐ’์„ ์ €์žฅํ•˜๊ณ  ์ฝ์„ ์ˆ˜ ์žˆ๋‹ค.

ํ•˜๋‚˜์˜ ๊ฐ’์„ ์ €์žฅํ•  ์ˆ˜ ์žˆ๋Š” ๋ฉ”๋ชจ๋ฆฌ์˜ ๊ณต๊ฐ„. ํ”„๋กœ๊ทธ๋žจ์— ์˜ํ•ด์„œ ์ˆ˜์‹œ๋กœ ๊ฐ™์ด ๋ณ€๋™๋  ์ˆ˜ ์žˆ๋‹ค. ํ•˜๋‚˜์˜ ๋ณ€์ˆ˜์—๋Š” ์˜ค์ง ํ•˜๋‚˜์˜ ๊ฐ’๋งŒ ์ €์žฅํ•  ์ˆ˜ ์žˆ๊ณ , ์ž๋ฐ”์—์„œ๋Š” ์„ ์–ธ๋œ ๋ณ€์ˆ˜์— ํ•œ ๊ฐ€์ง€ ์ข…๋ฅ˜์˜ ๊ฐ’๋งŒ ์ €์žฅํ•  ์ˆ˜ ์žˆ๋‹ค.
- ๋กœ์ปฌ ๋ณ€์ˆ˜(์ง€์—ญ ๋ณ€์ˆ˜): ๋ฉ”์„œ๋“œ ๋ธ”๋ก ๋‚ด์—์„œ ์„ ์–ธ๋œ ๋ณ€์ˆ˜. ๋กœ์ปฌ ๋ณ€์ˆ˜๋Š” ๋ฉ”์†Œ๋“œ ์‹คํ–‰์ด ๋๋‚˜๋ฉด ๋ฉ”๋ชจ๋ฆฌ์—์„œ ์ž๋™์œผ๋กœ ์—†์–ด์ง„๋‹ค.

๋ณ€์ˆ˜ ์„ ์–ธ: ์–ด๋–ค ์‹๋ณ„์ž๋ฅผ ๊ฐ–๊ณ , ์–ด๋–ค ๋ฐ์ดํ„ฐ๋ฅผ ๊ฐ€์ง€๊ณ  ์‹œ์ž‘ํ•˜๋Š” ๋ณ€์ˆ˜๋ผ๋Š” ๊ฒƒ์„ ์•Œ๋ฆฌ๋Š” ๊ฒƒ
ํ• ๋‹น: ๋ณ€์ˆ˜์— ๊ฐ’์„ ๋„ฃ๊ฑฐ๋‚˜ ์ €์žฅํ•˜๋Š” ๊ฒƒ์ด๋‹ค. (๋ฉ”๋ชจ๋ฆฌ์— ๋ณ€์ˆ˜์˜ ๊ฐ’์ด ๋“ค์–ด๊ฐˆ ๊ณต๊ฐ„์„ ํ• ๋‹นํ•ด์•ผ ํ•˜๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค.)
์ฐธ์กฐ: ๋ณ€์ˆ˜์— ์ ‘๊ทผํ•˜๋Š” ๊ฒƒ์ด๋‹ค.


2) ๋ณ€์ˆ˜ ์„ ์–ธ: ๋ณ€์ˆ˜์— ์–ด๋–ค ํƒ€์ž…์˜ ๋ฐ์ดํ„ฐ๋ฅผ ์ €์žฅํ• ์ง€, ๋ณ€์ˆ˜ ์ด๋ฆ„์ด ๋ฌด์—‡์ธ์ง€ ๊ฒฐ์ •ํ•˜๋Š” ๊ฒƒ์ด๋‹ค.

3) ๋ณ€์ˆ˜ ์‚ฌ์šฉ: ๋ณ€์ˆ˜์˜ ๊ฐ’์„ ์ฝ๊ฑฐ๋‚˜ ๋ณ€๊ฒฝํ•˜๋Š” ๊ฒƒ์ด๋‹ค. ๋ณ€์ˆ˜๋Š” ์ถœ๋ ฅ๋ฌธ์ด๋‚˜ ์—ฐ์‚ฐ์‹ ๋‚ด๋ถ€์—์„œ ์‚ฌ์šฉ๋˜์–ด ๋ณ€์ˆ˜์— ์ €์žฅ๋œ ๊ฐ’์„ ์ถœ๋ ฅํ•˜๊ฑฐ๋‚˜ ์—ฐ์‚ฐ์— ์‚ฌ์šฉํ•œ๋‹ค.

4) ๋ณ€์ˆ˜ ์‚ฌ์šฉ ๋ฒ”์œ„: ๋ณ€์ˆ˜๋Š” ์ž์‹ ์ด ์„ ์–ธ๋œ ์œ„์น˜์—์„œ ์ž์‹ ์ด ์†ํ•œ ๋ธ”๋ก ๋‚ด๋ถ€๊นŒ์ง€๋งŒ ์‚ฌ์šฉ์ด ๊ฐ€๋Šฅํ•˜๊ณ  ๋ฐ–์—์„œ๋Š” ์‚ฌ์šฉํ•  ์ˆ˜ ์—†๋‹ค. 


2.2 ๊ธฐ๋ณธ ํƒ€์ž… p. 59

์ž๋ฐ”๊ฐ€ ์ œ๊ณตํ•˜๋Š” ๊ธฐ๋ณธ (primitive) ํƒ€์ž…์€ ์ด 8๊ฐœ์ด๋‹ค.

๊ตฌ๋ถ„ ์ €์žฅ๋˜๋Š” ๊ฐ’์— ๋”ฐ๋ฅธ ๋ถ„๋ฅ˜ ํƒ€์ž…์˜ ์ข…๋ฅ˜
๊ธฐ๋ณธ ํƒ€์ž… ์ •์ˆ˜ ํƒ€์ž… byte, char, short, int, long
์‹ค์ˆ˜ ํƒ€์ž… float, double
๋…ผ๋ฆฌ ํƒ€์ž… boolean

1) ์ •์ˆ˜ ํƒ€์ž… p. 60

๋ฉ”๋ชจ๋ฆฌ ์‚ฌ์šฉ ํฌ๊ธฐ ์ •๋„๋Š” ์•Œ๊ณ  ์žˆ์–ด์•ผ ํ˜•๋ณ€ํ™˜์ด ์ดํ•ด๋œ๋‹ค.

ํƒ€์ž… ๋ฉ”๋ชจ๋ฆฌ ์‚ฌ์šฉ ํฌ๊ธฐ ์ €์žฅ๋˜๋Š” ๊ฐ’์˜ ํ—ˆ์šฉ ๋ฒ”์œ„
byte 1 byte 8 bit -2^7 ~ (2^7-1) -128 ~ 127
short 2 byte 16 bit -2^15 ~ (2^15-1) -32,768 ~ 32,767
char 2 byte 16 bit 0 ~ (2^16 - 1) 0 ~ 65535(์œ ๋‹ˆ์ฝ”๋“œ)
int 4 byte 32 bit -2^31 ~ (2^31 - 1) -2,147,483,648 ~ 2,147,483,647
long 8 byte 64 bit -2^63 ~ (2^63 - 1) -9,223,372,036,854,775,808
~ 9,223,372,036,854,775,807

๋ณดํ†ต int๋ฅผ ์“ด๋‹ค. ex) ์‡ผํ•‘๋ชฐ ๊ฐ€๊ฒฉ์„ ์ƒ๊ฐํ•ด ๋ณธ๋‹ค.


The bit is the most basic unit of information in computing and digital communications. The name is a portmanteau of binary digit. The bit represents a logical state with one of two possible values.
ํ˜ผ์„ฑ์–ด: A portmanteau (pronounced port-MAN-toe) is a word made by blending at least two words.

์ธ๊ฐ„ ์„ธ๊ณ„: 10์ง„์ˆ˜
: 10

์ง„์ˆ˜ ์ปดํ“จํ„ฐ(๊ธฐ๊ณ„์–ด): 2์ง„์ˆ˜

0 0 0 0 1 0 1 0

 

์ผ๋‹จ ๋ถ€ํ˜ธ ๋น„ํŠธ๋Š” ์ €์žฅ๋œ ์ˆ˜๊ฐ€ ์Œ์ˆ˜์ธ์ง€ ์–‘์ˆ˜์ธ์ง€ ๊ตฌ๋ถ„ํ•˜๋ ค๋Š” ๋ชฉ์ ์œผ๋กœ ์‚ฌ์šฉ๋œ๋‹ค. ์ €์žฅํ•˜๋ ค๋Š” ๋ชฉ์ ์— ๋”ฐ๋ผ ๋ถ€ํ˜ธ ๋น„ํŠธ๊ฐ€ ์žˆ์„ ์ˆ˜๋„ ์žˆ๊ณ  ์—†์„ ์ˆ˜๋„ ์žˆ๋‹ค. ๋งŒ์•ฝ ๋ถ€ํ˜ธ ๋น„ํŠธ๊ฐ€ ์žˆ์„ ๊ฒฝ์šฐ์—๋Š” ๊ฐ€์žฅ ๋†’์€ ๋น„ํŠธ (10000000์—์„œ๋Š” 1์ด ๊ฐ€์žฅ ๋†’์€ ๋น„ํŠธ๊ฐ€ ๋˜๊ฒ ์ง€์š”. ๋น„ํŠธ๋Š” 2์ง„์ˆ˜์˜ ์ž๋ฆฟ์ˆ˜๋‹ˆ๊นŒ์š”.)๊ฐ€ ๋ถ€ํ˜ธ ๋น„ํŠธ๊ฐ€ ๋œ๋‹ค.
์ฐธ๊ณ : https://m.blog.naver.com/PostView.naver?isHttpsRedirect=true&blogId=kmc7468&logNo=220842771599


1. ์ •์ˆ˜ ๋ฆฌํ„ฐ๋Ÿด int

์˜ˆ์ œ) 
2์ง„์ˆ˜: 0๊ณผ 1์„ ์‚ฌ์šฉํ•˜๋Š” ์ˆ˜์˜ ์ฒด๊ณ„ (๊ธฐ๊ณ„์–ด)
8์ง„์ˆ˜: 0, 1, 2, 3, 4, 5, 6, 7์„ ์‚ฌ์šฉํ•˜๋Š” ์ˆ˜์˜ ์ฒด๊ณ„
10์ง„์ˆ˜: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ์ˆ˜์˜ ์ฒด๊ณ„ (์ธ๊ฐ„)
16์ง„์ˆ˜: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ์ˆ˜์˜ ์ฒด๊ณ„

public class IntegerLiteralExample {
	public static void main(String[] args) {
			int var1 = 0b1011; //2์ง„์ˆ˜ (๊ธฐ๊ณ„์–ด)
			int var2 = 0206;   //8์ง„์ˆ˜
			int var3 = 365;	   //10์ง„์ˆ˜ (์ธ๊ฐ„)
			int var4 = 0xB3;   //16์ง„์ˆ˜
			
			System.out.println("var1: "+var1);
			System.out.println("var2: "+var2);
			System.out.println("var3: "+var3);
			System.out.println("var4: "+var4);
	}
}


๊ฒฐ๊ณผ)

var1: 11
var2: 134
var3: 365
var4: 179

2. byte ํƒ€์ž… ๋ณ€์ˆ˜

์˜ˆ์ œ) byte ํƒ€์ž…์˜ ๋ฒ”์œ„๋Š” -128~127์ด๋‹ค.

public class ByteExample {
	public static void main(String[] args) {
		byte var1 = -128;
		byte var2 = -30;
		byte var3 = 0;
		byte var4 = 30;
		byte var5 = 127;
		//byte var6 = 128;
		
		System.out.println("var1: "+var1);
		System.out.println("var2: "+var2);
		System.out.println("var3: "+var3);
		System.out.println("var4: "+var4);
		System.out.println("var5: "+var5);
		//System.out.println("var6: "+var6);
}
}


๊ฒฐ๊ณผ)

var1: -128
var2: -30
var3: 0
var4: 30
var5: 127

3. long ํƒ€์ž… ๋ณ€์ˆ˜ 

์˜ˆ์ œ) long ํƒ€์ž… ๋ณ€์ˆ˜: ์ •์ˆ˜ ๋ฆฌํ„ฐ๋Ÿด์ด int ํƒ€์ž…์˜ ํ—ˆ์šฉ ๋ฒ”์œ„ (-2,147,483,648 ~ 2,147,483,647)๋ฅผ ์ดˆ๊ณผํ•  ๊ฒฝ์šฐ 
์ •์ˆ˜ ๋ฆฌํ„ฐ๋Ÿด ๋’ค์— ์†Œ๋ฌธ์ž l์ด๋‚˜ ๋Œ€๋ฌธ์ž L์„ ๋ถ™์ธ๋‹ค. 

public class LongExample {
	public static void main(String[] args) {
		long var1 = 10;
		long var2 = 20L;
		//long var3 = 1000000000000; 
		long var4 = 1000000000000L; 
		
		System.out.println("var1: "+var1);
		System.out.println("var2: "+var2);
		//System.out.println("var3: "+var3);
		System.out.println("var4: "+var4);
}
}


๊ฒฐ๊ณผ)

var1: 10
var2: 20
var4: 1000000000000

- ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ์™€ ๋‹ค๋ฅด๊ฒŒ ์ž๋ฐ”๋Š” ๋ฌธ์ž์™€ ๋ฌธ์ž์—ด์„ ๊ตฌ๋ถ„ํ•œ๋‹ค.

4. char ํƒ€์ž… p. 63

๋ฌธ์ž: ํ•œ ๊ธ€์ž, ' (์ž‘์€ ๋”ฐ์˜ดํ‘œ)๋กœ ๊ฐ์‹ผ๋‹ค. (ex. ๊ฐ€, ๋‚˜, A, B)
๋ฌธ์ž๋„ ์ €์žฅํ•˜๊ณ  ์ˆซ์ž๋„ ์ €์žฅํ•œ๋‹ค. 

char a = '์•ˆ';

ex) ์„ฑ๋ณ„ (๋‚จ, ๋…€) (M, F)

char var1 = 'A';
char var2 = 'B';
char var3 = '๊ฐ€';
char var4 = '๊ฐ';
char c = 65; //10์ง„์ˆ˜
car c = 0x0041; //16์ง„์ˆ˜

 

์œ ๋‹ˆ์ฝ”๋“œ(unicode): ์„ธ๊ณ„ ๊ฐ๊ตญ์˜ ๋ฌธ์ž๋“ค์„ ์ฝ”๋“œ๊ฐ’์œผ๋กœ ๋งคํ•‘ํ•œ ๊ตญ์ œ ํ‘œ์ค€ ๊ทœ์•ฝ์ด๋‹ค. 
์œ ๋‹ˆ์ฝ”๋“œ๋Š” ํ•˜๋‚˜์˜ ๋ฌธ์ž์— ๋Œ€ํ•ด ํ•˜๋‚˜์˜ ์ฝ”๋“œ๊ฐ’์„ ๋ถ€์—ฌํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์˜๋ฌธ 'A' ๋ฐ ํ•œ๊ธ€ '๊ฐ€'๋„ ํ•˜๋‚˜์˜ ์ฝ”๋“œ ๊ฐ’์„ ๊ฐ€์ง„๋‹ค.

์ž๋ฐ”๋Š” ๋ชจ๋“  ๋ฌธ์ž๋ฅผ ์œ ๋‹ˆ์ฝ”๋“œ๋กœ ์ฒ˜๋ฆฌํ•œ๋‹ค. 

์•„์Šคํ‚ค ์ฝ”๋“œํ‘œ:
ASCII, abbreviated from American Standard Code for Information Interchange, is a character encoding standard for electronic communication. ASCII codes represent text in computers, telecommunications equipment, and other devices.  
ex) ๋ฌธ์ž 'A'๋Š” 65๋ผ๋Š” ์œ ๋‹ˆ์ฝ”๋“œ๋ฅผ ๊ฐ€์ง„๋‹ค.

ํ•œ๊ธ€: UNICODE HANGUL SYLLABLES
์ฐธ๊ณ : https://blog.makebyhand.co.kr/227

https://en.wikipedia.org/wiki/Hangul_Syllables

์˜ˆ์ œ) char ํƒ€์ž… 

public class CharExample {
	public static void main(String[] args) {
		char c1 = 'A'; //๋ฌธ์ž๋ฅผ ์ง์ ‘ ์ €์žฅ 
		char c2 = 65; //10์ง„์ˆ˜๋กœ ์ €์žฅ
		char c3 = '\u0041'; //16์ง„์ˆ˜๋กœ ์ €์žฅ 
		
		char c4 = '๊ฐ€'; //๋ฌธ์ž๋ฅผ ์ง์ ‘ ์ €์žฅ
		char c5 = 44032; //10์ง„์ˆ˜๋กœ ์ €์žฅ
		char c6 = '\uac00'; //16์ง„์ˆ˜๋กœ ์ €์žฅ 
		
		System.out.println(c1);
		System.out.println(c2);
		System.out.println(c3);
		System.out.println(c4);
		System.out.println(c5);
		System.out.println(c6);
	}
}


๊ฒฐ๊ณผ) ์œ„์˜ ์•„์Šคํ‚ค์ฝ”๋“œํ‘œ์—์„œ ์•Œ ์ˆ˜ ์žˆ๋“ฏ์ด 65๋Š” A์ด๋‹ค. (10์ง„์ˆ˜) 
\u: 16์ง„์ˆ˜ ์œ ๋‹ˆ์ฝ”๋“œ์— ํ•ด๋‹นํ•˜๋Š” ๋ฌธ์ž๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค. 0041: A (16์ง„์ˆ˜)
44032: ๊ฐ€ (UNICODE HANGUL SYLLABLES)
\uac00: ๊ฐ€ (Hangul Syllables is a Unicode block containing precomposed Hangul syllable blocks for modern Korean.)

A
A
A
๊ฐ€
๊ฐ€
๊ฐ€

5. String ํƒ€์ž… p. 64

์ž‘์€๋”ฐ์˜ดํ‘œ(')๋กœ ๊ฐ์‹ผ ๋ฌธ์ž๋Š” char ํƒ€์ž… ๋ณ€์ˆ˜์— ์ €์žฅ๋˜์–ด ์œ ๋‹ˆ์ฝ”๋“œ๋กœ ์ €์žฅ๋˜์ง€๋งŒ,
ํฐ๋”ฐ์˜ดํ‘œ(")๋กœ ๊ฐ์‹ผ ๋ฌธ์ž ๋˜๋Š” ์—ฌ๋Ÿฌ ๊ฐœ์˜ ๋ฌธ์ž๋“ค์€ ์œ ๋‹ˆ์ฝ”๋“œ๋กœ ๋ฐ˜ํ™˜๋˜์ง€ ์•Š๋Š”๋‹ค.

์ฐธ์กฐํ˜• ํƒ€์ž…์ด๋‹ค. ๊ธฐ๋ณธํ˜• ํƒ€์ž… X. String์ด๋ผ๋Š” ๊ฐ์ฒด๋กœ ์ €์žฅํ•œ๋‹ค. 

์ฐธ์กฐํ˜• ๋ณ€์ˆ˜๋Š” ๊ธฐ๋ณธํ˜• ๋ณ€์ˆ˜์™€๋Š” ๋‹ค๋ฅด๊ฒŒ ์‹ค์ œ ๊ฐ’์„ ๊ทธ๋Œ€๋กœ ์ €์žฅํ•˜๋Š” ๊ณต๊ฐ„์ด ์•„๋‹ˆ๋ผ
Heap์˜์—ญ์— ๊ฐ’์ด ์ €์žฅ๋œ ๊ณต๊ฐ„์˜ ์ฃผ์†Œ ๊ฐ’์„ ์ €์žฅํ•˜๋Š” ๊ณต๊ฐ„์ด๋ผ๋Š” ๊ฒƒ์ด๋‹ค.
์ฆ‰, ๊ธฐ๋ณธํ˜• ๋ณ€์ˆ˜๋Š” ์‹ค์ œ ๊ฐ’์„ ์ €์žฅํ•˜๊ณ  ์ฐธ์กฐํ˜• ๋ณ€์ˆ˜๋Š” ์ฃผ์†Œ ๊ฐ’์„ ์ €์žฅํ•˜๊ณ  ์žˆ๋Š” ๊ฒƒ์ด๋‹ค.
์ฐธ๊ณ : https://colossus-java-practice.tistory.com/7

๋ฌธ์ž์—ด(๋ฌธ์ž + ๋ฐฐ์—ด): " (ํฐ ๋”ฐ์˜ดํ‘œ)๋กœ ๊ฐ์‹ผ๋‹ค. (ex. ์•ˆ๋…•, ์•ˆ๋…•ํ•˜์„ธ์š”)
๋ฌธ์ž ํ•˜๋‚˜ํ•˜๋‚˜๋ฅผ ๋ฐฐ์—ด์— ์ €์žฅํ•œ๋‹ค. 

String b = "์•ˆ๋…•ํ•˜์„ธ์š”";

ex) ์•„์ด๋””, ๋น„๋ฐ€๋ฒˆํ˜ธ (๋ฌธ์ž, ์—ฌ๋Ÿฌ ๊ธ€์ž์ด๋ฏ€๋กœ)
ex) ์„ฑ๋ณ„ (๋‚จ์ž, ์—ฌ์ž)๋กœ ์ €์žฅ

ex) ์ „ํ™”๋ฒˆํ˜ธ๋ฅผ ์ •์ˆ˜ ํƒ€์ž…์œผ๋กœ ์ €์žฅํ•˜๋ฉด 010์˜ 0์€ ์—†์–ด์ง„๋‹ค. (cf. ๋‚˜์ด๋Š” int)

์ด์Šค์ผ€์ดํ”„(escape) ๋ฌธ์ž: ๋ฌธ์ž์—ด ๋‚ด๋ถ€์— \(์—ญ์Šฌ๋ž˜์‹œ)๊ฐ€ ๋ถ™์€ ๋ฌธ์ž
\ + ์‚ฌ์šฉํ•˜๊ณ  ์‹ถ์€ ํŠน์ • ๋ฌธ์ž (ex. \"์ž๋ฐ”\")  

์ด์Šค์ผ€์ดํ”„ ๋ฌธ์ž ์ถœ๋ ฅ ์šฉ๋„
\t ํƒญ๋งŒํผ ๋„์šด๋‹ค.
\n ์ค„ ๋ฐ”๊ฟˆ(๋ผ์ธ ํ”ผ๋“œ) ์‹œ์Šคํ…œ: unix, window
\r ์บ๋ฆฌ์ง€๋ฆฌํ„ด ์‹œ์Šคํ…œ: mac, window
\" " ์ถœ๋ ฅ
\' ' ์ถœ๋ ฅ
\\ \ ์ถœ๋ ฅ
\u16์ง„์ˆ˜ 16์ง„์ˆ˜ ์œ ๋‹ˆ์ฝ”๋“œ์— ํ•ด๋‹นํ•˜๋Š” ๋ฌธ์ž๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค.

 \n is specifically used to move to a new line,
while \r is used for a carriage return, which moves the cursor back to the beginning of the current line.

์˜ˆ์ œ)

public class EscapeExample {
	public static void main(String[] args) {
		System.out.println("๋ฒˆํ˜ธ\t์ด๋ฆ„\t์ง์—…");
		System.out.println("ํ–‰ ๋‹จ์œ„ ์ถœ๋ ฅ\n");
		System.out.println("ํ–‰ ๋‹จ์œ„ ์ถœ๋ ฅ\n");
		System.out.println("์šฐ๋ฆฌ๋Š” \"๊ฐœ๋ฐœ์ž\"์ž…๋‹ˆ๋‹ค.");
		System.out.println("๋ด„\\์—ฌ๋ฆ„\\๊ฐ€์„\\๊ฒจ์šธ");
	}
}

๊ฒฐ๊ณผ)

๋ฒˆํ˜ธ	์ด๋ฆ„	์ง์—…
ํ–‰ ๋‹จ์œ„ ์ถœ๋ ฅ

ํ–‰ ๋‹จ์œ„ ์ถœ๋ ฅ

์šฐ๋ฆฌ๋Š” "๊ฐœ๋ฐœ์ž"์ž…๋‹ˆ๋‹ค.
๋ด„\์—ฌ๋ฆ„\๊ฐ€์„\๊ฒจ์šธ

2) ์‹ค์ˆ˜ ํƒ€์ž… p. 66

ํƒ€์ž… ๋ฉ”๋ชจ๋ฆฌ ์‚ฌ์šฉ ํฌ๊ธฐ ์ €์žฅ๋˜๋Š” ๊ฐ’์˜ ํ—ˆ์šฉ ๋ฒ”์œ„(์–‘์ˆ˜ ๊ธฐ์ค€) ์ •๋ฐ€๋„(์†Œ์ˆ˜์  ์ดํ•˜ ์ž๋ฆฌ)
float 4byte 32bit (1.4*10^-45) ~ (3.4*10^38) 7์ž๋ฆฌ
double 8byte 64bit (4.9*10^-324) ~ (1.8*10^308) 15์ž๋ฆฌ


์ž๋ฐ”๋Š” ์‹ค์ˆ˜ ๋ฆฌํ„ฐ๋Ÿด์„ ๊ธฐ๋ณธ์ ์œผ๋กœ double ํƒ€์ž…์œผ๋กœ ํ•ด์„ํ•˜๊ธฐ ๋•Œ๋ฌธ์— double ํƒ€์ž… ๋ณ€์ˆ˜์— ์ €์žฅํ•ด์•ผ ํ•œ๋‹ค.
์‹ค์ˆ˜ ๋ฆฌํ„ฐ๋Ÿด์„ float ํƒ€์ž…์œผ๋กœ ์ €์žฅํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด ๋ฆฌํ„ฐ๋Ÿด ๋’ค์— ์†Œ๋ฌธ์ž f๋‚˜ ๋Œ€๋ฌธ์ž F๋ฅผ ๋ถ™์—ฌ ์ปดํŒŒ์ผ๋Ÿฌ๊ฐ€ FLOAT ํƒ€์ž…์ž„์„ ์•Œ ์ˆ˜ ์žˆ๋„๋ก ํ•ด์•ผ ํ•œ๋‹ค.

double ํƒ€์ž…์€ float ํƒ€์ž…๋ณด๋‹ค 2๋ฐฐ ์ •๋„ ์ •๋ฐ€๋„๊ฐ€ ๋†’๊ธฐ ๋•Œ๋ฌธ์— ์ข€ ๋” ์ •ํ™•ํ•œ ๋ฐ์ดํ„ฐ ์ €์žฅ์ด ๊ฐ€๋Šฅํ•˜๋‹ค. 

์˜ˆ์ œ)

public class FloatDoubleExample {
	public static void main(String[] args) {
		float var2 = 3.14f;
		double var3 = 3.14;
		
		System.out.println("var2: "+var2);
		System.out.println("var3: "+var3);
		
		//๋ฐ์ดํ„ฐ ์†์‹ค ๋ฐฉ์ง€๋กœ float ํƒ€์ž…์ด double ํƒ€์ž…์ฒ˜๋Ÿผ ์ฑ„์šฐ๋ ค๊ณ  ํ•˜๋ฏ€๋กœ ๋‘˜์˜ ๊ฐ’์€ ๊ฐ™์ง€ ์•Š๋‹ค. (์ •๋ฐ€๋„๊ฐ€ ๋‹ค๋ฅด๋‹ค.)
		float var4 = 0.123456789f;
		double var5 = 0.123456789;
		
		System.out.println(var4==var5);
		
		//e ์‚ฌ์šฉํ•˜๊ธฐ
		double var6 = 3e6;
		float var7 = 3e6F;
		double var8 = 2e-3;
		
		System.out.println("var6: "+var6);
		System.out.println("var7: "+var7);
		System.out.println("var8: "+var8);
	}
}

๊ฒฐ๊ณผ) ๋ฐ์ดํ„ฐ ์†์‹ค ๋ฐฉ์ง€๋กœ float ํƒ€์ž…์ด double ํƒ€์ž…์ฒ˜๋Ÿผ ์ฑ„์šฐ๋ ค๊ณ  ํ•˜๋ฏ€๋กœ ๋‘˜์˜ ๊ฐ’์€ ๊ฐ™์ง€ ์•Š๋‹ค. (์ •๋ฐ€๋„๊ฐ€ ๋‹ค๋ฅด๋‹ค.)

var2: 3.14
var3: 3.14
false
var6: 3000000.0
var7: 3000000.0
var8: 0.002

e๋Š” ์ง€์ˆ˜์ด๋‹ค. ex) 3e6 = 3*10^6, 2e-3 = 2*10^-3


3) ๋…ผ๋ฆฌ ํƒ€์ž…

์ฐธ๊ณผ ๊ฑฐ์ง“์„ ์˜๋ฏธํ•˜๋Š” ๋…ผ๋ฆฌ ๋ฆฌํ„ฐ๋Ÿด๋กœ true์™€ false๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค. 1byte ํฌ๊ธฐ์˜ boolean ํƒ€์ž… ๋ณ€์ˆ˜์— ์ €์žฅํ•  ์ˆ˜ ์žˆ๋‹ค. 

boolean stop = true;
boolean state = false;

์˜ˆ์ œ) boolean ํƒ€์ž…

public class BooleanExample {
	public static void main(String[] args) {
		boolean stop = true;
		if(stop) {
			System.out.println("์ค‘์ง€ํ•ฉ๋‹ˆ๋‹ค.");
		}
		else {
			System.out.println("์‹œ์ž‘ํ•ฉ๋‹ˆ๋‹ค.");
		}
	}
}


๊ฒฐ๊ณผ) stop ๋ณ€์ˆ˜๊ฐ€ true ๊ฐ’์„ ๊ฐ€์ง€๊ณ  ์žˆ๊ธฐ ๋•Œ๋ฌธ์— if ๋ธ”๋ก์ด ์‹คํ–‰๋˜์–ด "์ค‘์ง€ํ•ฉ๋‹ˆ๋‹ค."๊ฐ€ ์ถœ๋ ฅ๋œ๋‹ค.

์ค‘์ง€ํ•ฉ๋‹ˆ๋‹ค.

๋งˆ๋ฌด๋ฆฌ p. 70

1) ์ •์ˆ˜ ํƒ€์ž…: ์ •์ˆ˜๋ฅผ ์ €์žฅํ•  ์ˆ˜ ์žˆ๋Š” ํƒ€์ž…
ex) byte, short, int, long

2) char ํƒ€์ž…: 
์ž‘์€๋”ฐ์˜ดํ‘œ(')๋กœ ๊ฐ์‹ผ ํ•˜๋‚˜์˜ ๋ฌธ์ž ๋ฆฌํ„ฐ๋Ÿด์„ ์ €์žฅํ•  ์ˆ˜ ์žˆ๋Š” ํƒ€์ž…
๋ฆฌํ„ฐ๋Ÿด(literal): ์†Œ์Šค ์ฝ”๋“œ์—์„œ ํ”„๋กœ๊ทธ๋ž˜๋จธ์— ์˜ํ•ด ์ง์ ‘ ์ž…๋ ฅ๋œ ๊ฐ’
In computer science, a literal is a notation for representing a fixed value in source code. 

3) String ํƒ€์ž…: 
ํฐ๋”ฐ์˜ดํ‘œ(")๋กœ ๊ฐ์‹ผ ๋ฌธ์ž์—ด์„ ์ €์žฅํ•  ์ˆ˜ ์žˆ๋Š” ํƒ€์ž… ์ฐธ์กฐํ˜• ํƒ€์ž…์ด๋‹ค. ๊ธฐ๋ณธํ˜• ํƒ€์ž… X.

4) ์‹ค์ˆ˜ ํƒ€์ž…: 
์‹ค์ˆ˜(์†Œ์ˆ˜์ ์ด ์žˆ๋‹ค.)๋ฅผ ์ €์žฅํ•  ์ˆ˜ ์žˆ๋Š” ํƒ€์ž…
ex) float, double 

5) boolean ํƒ€์ž…: 
์ฐธ๊ณผ ๊ฑฐ์ง“์„ ์˜๋ฏธํ•˜๋Š” true์™€ false๋ฅผ ์ €์žฅํ•  ์ˆ˜ ์žˆ๋Š” ํƒ€์ž…


728x90
๋ฐ˜์‘ํ˜•
Comments