JAVA์˜ ์ •์„ (ch 6) (2)

Du-Hyeon, Kimยท2023๋…„ 7์›” 18์ผ
0

JAVA

๋ชฉ๋ก ๋ณด๊ธฐ
7/11
post-thumbnail

mufxxkingsibalgyeongjangsoceity
?ukw
foorp

๐Ÿ’ป 6. OOPs (2)

๐Ÿคฃ ๋งค์„œ๋“œ๋ฅผ ํ†ตํ•œ instance variable ๋ณ€๊ฒฝ

public class Time 
{
	private int hour;
	private int minute;
	private floast seconds;

	public void setHour(int h){
		if(h<0 || h>23) return;
		hour = h;
	}
}

private์œผ๋กœ hour์„ ์„ ์–ธํ•จ์œผ๋กœ์„œ
๋ณ€์ˆ˜ ๊ฐ’์„ ์ง์ ‘๋ณ€๊ฒฝํ•˜์ง€ ๋ชปํ•˜๊ฒŒ ํ•˜๊ณ , ๋งค์„œ๋“œ๋ฅผ ํ†ตํ•ด์„œ๋งŒ ๋ณ€๊ฒฝ๊ฐ€๋Šฅํ•˜๊ฒŒ ํ•จ.
๋”ฐ๋ผ์„œ class์˜ property๋“ค์˜ ์กฐ๊ฑด๋“ค์„ ๋งค์„œ๋“œ๋ฅผ ํ†ตํ•ด์„œ ๋ฏธ๋ฆฌ ์ œํ•œ๊ฐ€๋Šฅํ•จ!!

๐Ÿคฃ ๋ณ€์ˆ˜์˜ ์ข…๋ฅ˜

๋ณ€์ˆ˜์˜ ์ข…๋ฅ˜์„ ์–ธ์œ„์น˜์ƒ์„ฑ์‹œ๊ธฐ
class variableclass blockํด๋ž˜์Šค๊ฐ€ ๋ฉ”๋ชจ๋ฆฌ์— ์˜ฌ๋ผ๊ฐˆ ๋•Œ
instance variableclass blockinstance๊ฐ€ ์ƒ์„ฑ๋˜์—ˆ์„ ๋•Œ
local variableclass ์˜์—ญ ์ด์™ธ์˜ ์˜์—ญ๋ณ€์ˆ˜ ์„ ์–ธ๋ฌธ์ด ์ˆ˜ํ–‰๋˜์—ˆ์„ ๋•Œ
  • ํ•œ class์˜ class variable์€ ๋ชจ๋“  ์ธ์Šคํ„ด์Šค์—์„œ ๊ณตํ†ต๋œ ์ €์žฅ๊ณต๊ฐ„์„ ๊ณต์œ ํ•œ๋‹ค
  • instance๋ณ€์ˆ˜๋Š” instance ์ƒ์„ฑ ํ›„์— ์ ‘๊ทผ ๊ฐ€๋Šฅํ•˜์ง€๋งŒ,
    class variable์˜ ๊ฒฝ์šฐ class๋ช….class_variable๋กœ ์–ธ์ œ๋“ ์ง€ ํ˜ธ์ถœ ํ•  ์ˆ˜ ์žˆ๋‹ค.

๐Ÿคฃ ๋งค์„œ๋“œ๋ž€?

C์–ธ์˜ ํ•จ์ˆ˜ ์„ ์–ธ๊ณผ ๋™์ผํ•จ
๋‹ค๋งŒ, class์•ˆ์—์„œ class ๋ณ€์ˆ˜๋“ค์„ ๋Œ€์ฒด๋กœ ์ด์šฉํ•ด์„œ ๊ด€๊ณ„์„ค์ •์— ์šฉ์˜ํ•œ ํ•จ์ˆ˜

๐Ÿคฃ ๋งค์„œ๋“œ ํ˜ธ์ถœ ์‹œ ๋งค๊ฐœ๋ณ€์ˆ˜

  • ๋งค์„œ๋“ค ํ˜ธ์ถœ ์‹œ ๋งค๊ฐœ๋ณ€์ˆ˜
    ๊ธฐ๋ณธํ˜• ๋งค๊ฐœ๋ณ€์ˆ˜ : ๊ฐ’์„ ์ฝ์„ ์ˆ˜๋งŒ ์žˆ์Œ
    ์ฐธ์กฐํ˜• ๋งค๊ฐœ๋ณ€์ˆ˜ : ์ฃผ์†Œ๋ฅผ ๋ถˆ๋Ÿฌ์˜ค๊ธฐ ๋–„๋ฌธ์—, ๊ฐ’์„ ์ฝ๊ณ  ๋ณ€๊ฒฝ ๊ฐ€๋Šฅ
๊ธฐ๋ณธํ˜• ๋งค๊ฐœ๋ณ€์ˆ˜
static void change(int x) {
	x = 1000;
	System.out.println("change() : x = " + x);
}


์ฐธ์กฐํ˜• ๋งค๊ฐœ๋ณ€์ˆ˜
static void change(Data2 d) {
	d.x = 1000;
	System.out.println("change() : x = " + d.x);
}
  1. ๊ทธ๋ƒฅ ๋ชจ๋“  ๊ณผ์ •์—์„œ ๋ฐ˜ํ™˜ํ˜• ํƒ€์ž…๊ณผ returnํƒ€์ž…์€ ๊ฐ™์•„์•ผ๋จ
  2. ๋งค์„œ๋“œ ๋ฐ˜ํ™˜ ํƒ€์ž…๊ณผ ๋งค๊ฐœ๋ณ€์ˆ˜๋Š” ๊ธฐ๋ณธํ˜•, ์ฐธ์กฐํ˜• ๋ชจ๋‘ ๊ฐ€๋Šฅํ•จ

๐Ÿคฃ class method

  • static ๋งค์„œ๋“œ์ด๋ฆ„{} ์œผ๋กœ ์„ ์–ธํ•  ์ˆ˜ ์žˆ๋‹ค.
  • class varaible๊ณผ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ class method๋„ ์ธ์Šคํ„ด์Šค ์ƒ์„ฑ ์—†์ด
  • ํด๋ž˜์Šค๋ช….๋งค์„œ๋“œ๋ช… ์œผ๋กœ ํ˜ธ์ถœ ๊ฐ€๋Šฅํ•˜๋‹ค.

๋Œ€์ฒด๋กœ ์ธ์Šคํ„ด์Šค ๋ณ€์ˆ˜๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๋งค์„œ๋“œ๋Š” ์ธ์Šคํ„ด์Šค ๋งค์„œ๋“œ๋กœ
์ธ์Šคํ„ด์Šค ๋ณ€์ˆ˜ ์‚ฌ์šฉ์ด ์—†๋Š” ๋งค์„œ๋“œ๋Š” (static)ํด๋ž˜์Šค ๋งค์„œ๋“œ๋กœ ์„ ์–ธํ•œ๋‹ค.

๐Ÿคฃ ์ธ์Šคํ„ด์Šค ๋ณ€์ˆ˜๋ณด๋‹ค ์ง€์—ญ๋ณ€์ˆ˜๊ฐ€ ์šฐ์„ ์ˆœ์œ„

class MyMath2 {
	long a, b;
	
	//using instacne variable, method is declared in instance method
	long add()	{ return a + b; }
	long subtract()	{ return a - b; }
	long multiply()	{ return a * b; }
	double divide()	{ return a / b; }

	//using local varaible, method is declared in class method
	//as you see, the same variable name doesn't matter when it is local variable
	static long   add(long a, long b)	{ return a + b; }
	static long   subtract(long a, long b)	{ return a - b; }
	static long   multiply(long a, long b)	{ return a * b; }
	static double divide(long a, long b)	{ return a / (double)b; }
	
}


class Ex6_9 {
	public static void main(String args[]) {
		//using class method
		System.out.println(MyMath2.add(200L, 100L));
		System.out.println(MyMath2.subtract(200L, 100L));
		System.out.println(MyMath2.multiply(200L, 100L));
		System.out.println(MyMath2.divide(200L, 100L));
		
		//make instance
		MyMath2 mm = new MyMath2();
		mm.a = 200L;
		mm.b = 100L;
		System.out.println(mm.add());
		System.out.println(mm.subtract());
		System.out.println(mm.multiply());
		System.out.println(mm.divide());
   }
}

๐Ÿคฃ ์˜ค๋ฒ„๋กœ๋”ฉ(overloading)

  • ๋งค์„œ๋“œ์—์„œ ์ด๋ฆ„์€ ๊ฐ™๊ณ , ๋งค๊ฐœ๋ณ€์ˆ˜ ๊ฐœ์ˆ˜ ๋˜๋Š” ํƒ€์ž…์ด ๋‹ค๋ฅด๊ฒŒ ์ •์˜ํ•˜๋Š” ๊ฒƒ

์กฐ๊ฑด1. ๋งค์„œ๋“œ์˜ ์ด๋ฆ„์ด ๊ฐ™์•„์•ผ ํ•œ๋‹ค.
์กฐ๊ฑด2. ๋งค๊ฐœ๋ณ€์ˆ˜์˜ ๊ฐœ์ˆ˜ ๋˜๋Š” ํƒ€์ž…์ด ๋‹ฌ๋ผ์•ผํ•œ๋‹ค.

int add(int a, int b) {return a+b;}
int add(int x, int y) {return x+y;}
์˜ค๋ฒ„๋กœ๋”ฉ ์•„๋‹˜

int add(int a, int b) {return a+b;}
long add(int a, int b) {return (long)(a+b);}
์˜ค๋ฒ„๋กœ๋”ฉ ์•„๋‹˜

long add(int a, long b) {return a+b;}
long add(long a, int b) {return a+b;}
์˜ค๋ฒ„๋กœ๋”ฉ ๋งž์Œ
-> ๋“ค์–ด์˜ค๋Š” ๋งค๊ฐœ๋ณ€์ˆ˜ ํƒ€์ž…์— ๋”ฐ๋ผ์„œ ๋งค์„œ๋“œ๊ฐ€ ์•Œ์•„์„œ ํ˜ธ์ถœ๋จ

๐Ÿคฃ ์ƒ์„ฑ์ž(constructor)

  • ์ƒ์„ฑ์ž๋Š” ์ธ์Šคํ„ด์Šค๊ฐ€ ์ƒ์„ฑ๋  ๋•Œ ํ˜ธ์ถœ๋˜๋Š” '์ธ์Šคํ„ด์Šค ์ดˆ๊ธฐํ™” ๋งค์„œ๋“œ"์ด๋‹ค.
  • ์ƒ์„ฑ์ž์˜ ํ˜•์‹์€
  1. ์ƒ์„ฑ์ž์˜ ์ด๋ฆ„์€ ํด๋ž˜์Šค์˜ ์ด๋ฆ„๊ณผ ๊ฐ™์•„์•ผ ํ•œ๋‹ค.
  2. ์ƒ์„ฑ์ž๋Š” ๋ฆฌํ„ด ๊ฐ’์ด ์—†๋‹ค.
  3. ์ƒ์„ฑ์ž๋„ ์˜ค๋ฒ„๋กœ๋”ฉ์ด ๊ฐ€๋Šฅํ•˜๋‹ค.

์—ฐ์‚ฐ์ž new๊ฐ€ ์ธ์Šคํ„ด์Šค๋ฅผ ์ƒ์„ฑํ•˜๋Š” ๊ฒƒ์ด์ง€, ์ƒ์„ฑ์ž๊ฐ€ ์ธ์Šคํ„ด์Šค๋ฅผ ์ƒ์„ฑํ•˜๋Š” ๊ฒƒ์ด ์•„๋‹ˆ๋‹ค.

์ง€๋ ธ๋‹ค...

class Data_1 {
	int value;
}

class Data_2 {
	int value;

	Data_2(int x) {   //๋งค๊ฐœ๋ณ€์ˆ˜๊ฐ€ ์žˆ๋Š” ์ƒ์„ฑ์ž
		value = x;
	}
}

class Ex6_11 {
	public static void main(String[] args) {
		Data_1 d1 = new Data_1();
		Data_2 d2 = new Data_2(); // compile error
	}
}
  • ์šฐ๋ฆฌ๊ฐ€ ์ง€๊ธˆ๊นŒ์ง€ ์ƒ์„ฑ์ž๋ฅผ ์ž‘์„ฑํ•˜์ง€ ์•Š์€ ์ด์œ ๋Š” compiler์—์„œ ์ž๋™์œผ๋กœ ๊ธฐ๋ณธ ์ƒ์„ฑ์ž๋ฅผ ์ถ”๊ฐ€ํ•ด์ฃผ๊ธฐ ๋–„๋ฌธ์ด์˜€๋‹ค. (์ƒ์„ฑ์ž๊ฐ€ ์ž‘์„ฑ๋˜์–ด ์žˆ๋‹ค๋ฉด, ๊ธฐ๋ณธ์ƒ์„ฑ์ž๋Š” ๋งŒ๋“ค์–ด์ง€์ง€ ์•Š์Œ)
  • ์˜ˆ๋ฅผ ๋“ค์–ด,
class Data_1 {
	int value;
}
๊ฐ™์€ ๊ฒฝ์šฐ compileํŒŒ์ผ์—๋Š” ์•„๋งˆ
class Data_1 {
	Data_1() {}	//added
	int value;
}
๋กœ ์ž‘์„ฑ๋˜์—ˆ์„ ๊ฒƒ์ด๋‹ค.
  • ๋งค๊ฐœ๋ณ€์ˆ˜ ์žˆ๋Š” ์ƒ์„ฑ์ž์˜ instance ์ƒ์„ฑ
Data_2 d2 = new Data_2(); // compile error

-> ์ด๋Š” Data_2 class์— ์ƒ์„ฑ์ž๋ฅผ ๋งค๊ฐœ๋ณ€์ˆ˜๊ฐ€ ์žˆ๋„๋ก ์ •์˜ํ–ˆ๊ธฐ ๋–„๋ฌธ์— ์˜ณ๋ฐ”๋ฅธ ์ƒ์„ฑ์ž ํ˜•ํƒœ๋กœ ํ˜ธ์ถœ๋˜์ง€ ์•Š์•˜๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค.

  • ์•„๋ž˜ Car class๋ฅผ ๋ณด์ž
class Car {
	String color;
	String gearType;
	int door;

	Car() {}

	Car(String c, String g, int d) {
		color = c;
		gearType = g;
		door = d;
	}
}
  • Car๋ผ๋Š” class๋ช…
  • ๋™์ผํ•œ Car๋กœ ๊ธฐ๋ณธ์ƒ์„ฑ์ž ์„ ์–ธ
  • Car์˜ instance variable color, gearType, door๋ฅผ ์ง€์ •ํ•˜๋Š” ์ƒ์„ฑ์ž
  • Car c2 = new Car("white", "auto", 4);
    ๊ฐ€ ์‹คํ–‰๋˜๋Š” ์ˆœ์„œ
  1. c2๋ผ๋Š” car class ์ฃผ์†Œ๋ฅผ ์ €์žฅํ•  ์ˆ˜ ์žˆ๋Š” ์ฐธ์กฐํ˜• ๋ณ€์ˆ˜ ์„ ์–ธ
  2. new Car๋กœ Car instance ์ƒ์„ฑ
  3. ์ด๋•Œ, ๋งค๊ฐœ๋ณ€์ˆ˜๊ฐ€ ์žˆ๊ธฐ ๋•Œ๋ฌธ์— ๊ธฐ๋ณธํ˜• ์ƒ์„ฑ์ž๊ฐ€ ์•„๋‹ˆ๋ผ ์˜ค๋ฒ„๋กœ๋”ฉ๋œ ๋งค๊ฐœ๋ณ€์ˆ˜ 3๊ฐœ์งœ๋ฆฌ ์ƒ์„ฑ์ž๋กœ ์ธ์Šคํ„ด์Šค ์ดˆ๊ธฐํ™”

๐Ÿคฃ ์ƒ์„ฑ์ž์—์„œ ์ƒ์„ฑ์ž ํ˜ธ์ถœ

1. ์ƒ์„ฑ์ž ๋‚ด์—์„œ ๋‹ค๋ฅธ ์ƒ์„ฑ์ž ํ˜ธ์ถœ ๊ฐ€๋Šฅ
2. ๋‹จ!!!! ๋‹ค๋ฅธ ์ƒ์„ฑ์ž ํ˜ธ์ถœ์€ ๋ฐ˜๋“œ์‹œ ์ฒซ์ค„์—์„œ๋งŒ this๋กœ ๊ฐ€๋Šฅ

class Car2 {
	String color;		//     
	String gearType;	//    ำฑ       - auto( ฺต ), manual(    )
	int door;			//          

	Car2() {
		this("white", "auto", 4);
	}

	Car2(String color) {
		this(color, "auto", 4);
	}

	Car2(String color, String gearType, int door) {
		this.color = color;
		this.gearType = gearType;
		this.door = door;
	}
}
  • ์ƒ์„ฑ์ž ๋‚ด์—์„œ ์ƒ์„ฑ์ž๋ฅผ ์„ ์–ธํ•˜๋Š” ๊ณผ์ •์€ ์˜ต์…˜์„ ๋ถ™์ด์ง€ ์•Š์€ ์ˆœ์ • ์ž๋™์ฐจ๋ถ€ํ„ฐ ์˜ต์…˜์„ ์ ์ฐจ ์ถ”๊ฐ€ํ•˜๋Š” ๊ณผ์ •์œผ๋กœ ์ƒ๊ฐํ•ด๋„ ๋œ๋‹ค.
  • ์ƒ์„ฑ์ž ๋‚ด์—์„œ ์ƒ์„ฑ์ž๋ฅผ ํ˜ธ์ถœํ•˜๋Š” ๊ณผ์ •์€ ์ฝ”๋“œ์˜ ์ˆ˜์ •์ด ์ ˆ์•ฝ๋˜๊ณ , ์œ ์ง€๋ณด์ˆ˜๊ฐ€ ์‰ฌ์›Œ์ง„๋‹ค.

๐Ÿคฃ ๊ฐ์ฒด ์ž์‹ ์„ ๊ฐ€๋ฆฌํ‚ค๋Š” ๋ณ€์ˆ˜ this

this๋Š” ์ฐธ์กฐ๋ณ€์ˆ˜๋กœ ์ž๊ธฐ์ž์‹ ์„ ๊ฐ€๋ฆฌํ‚จ๋‹ค
C์–ธ์–ด์˜ ํฌ์ธํ„ฐ == JAVA์˜ ์ฐธ์กฐ๋ณ€์ˆ˜

1. ์•„๋ž˜์™€ ๊ฐ™์ด instance varaible๊ณผ ์ƒ์„ฑ์ž์˜ local varible์˜ ๋ณ€์ˆ˜๋ช…์ด ๋‹ค๋ฅด๋ฉฐ ์•„๋ฌด ๋ฌธ์ œ๊ฐ€ ์—†์œผ๋‚˜

Car(String c, String g, int d){
	color = c;
	gearType = g;
	door = d;
}

2. instance variable๊ณผ local variable์˜ ๋ณ€์ˆ˜๋ช…์ด ๊ฐ™์œผ๋ฉด, this๋ฅผ ์ด์šฉํ•ด์„œ intance variable๋กœ ์‚ฌ์šฉ๊ฐ€๋Šฅํ•˜๋‹ค.

Car(String color, String gear, int door){
	this.color = color;
	this.gearType = gearType;
	this.door = door;
}
//์ฝ”๋“œ์ด ๊ฐ€๋…์„ฑ์—์„œ this๋ณ€์ˆ˜๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ํŽธ์ด ์ข‹์„ ๋“ฏ ํ•˜๋‹ค.

๐Ÿคฃ ํด๋ž˜์Šค ๋‚ด ๋ณ€์ˆ˜์˜ ์ดˆ๊ธฐํ™”

  • ๋งด๋ฒ„๋ณ€์ˆ˜(ํด๋ž˜์Šค ๋ณ€์ˆ˜, ์ธ์Šคํ„ด์Šค ๋ณ€์ˆ˜)๋Š” ์ดˆ๊ธฐํ™”๊ฐ€ ์ž๋™์œผ๋กœ ๋จ(type default ๊ฐ’์œผ๋กœ)
  • ํด๋ž˜์Šค ๋‚ด ๋งค์„œ๋“œ์˜ ์ง€์—ญ๋ณ€์ˆ˜์˜ ๊ฒฝ์šฐ ์ž๋™ ์ดˆ๊ธฐํ™” ์•ˆ๋จ!!
    ๋”ฐ๋ผ์„œ, ์ง€์—ญ๋ณ€์ˆ˜๋Š” ์ดˆ๊ธฐํ™” ์ง„ํ–‰ ํ•„์ˆ˜!!

๐Ÿคฃ ๋งด๋ฒ„๋ณ€์ˆ˜์˜ ์ดˆ๊ธฐํ™”์˜ ํด๋ž˜์Šค ๋‚ด ์ดˆ๊ธฐํ™” ์ˆœ์„œ

๋งด๋ฒ„๋ณ€์ˆ˜์˜ ์ดˆ๊ธฐํ™”์™€ ํด๋ž˜์Šค ๋‚ด ์ดˆ๊ธฐํ™” ์ˆœ์„œ
1. ํด๋ž˜์Šค ๋ณ€์ˆ˜(cv) ์ดˆ๊ธฐํ™” -> ์ธ์Šคํ„ด์Šค ๋ณ€์ˆ˜(iv) ์ดˆ๊ธฐํ™”
2. ์ž๋™ ์ดˆ๊ธฐํ™” -> ๋ช…์‹œ์  ์ดˆ๊ธฐํ™”(๊ฐ„๋‹จ) -> ํด๋ž˜์Šค ์ดˆ๊ธฐํ™” ๋ธ”๋Ÿญ -> ์ธ์Šคํ„ด์Šค ์ดˆ๊ธฐํ™” ๋ธ”๋Ÿญ -> ์ƒ์„ฑ์ž

<๋ช…์‹œ์  ์ดˆ๊ธฐํ™”>
๋ณ€์ˆ˜ ์„ ์–ธ๊ณผ ๋™์‹œ์— ์ดˆ๊ธฐํ™”ํ•˜๋Š” ๊ฒƒ

int door = 4;
Engine e = ne Engine();

<Ex 1>

class Ex6_14 {
	static {
		System.out.println("static { }");
	}

	{
		System.out.println("{ }");
	}

	public Ex6_14() {
		System.out.println("์ƒ์„ฑ์ž");
	}

	public static void main(String args[]) {
		System.out.println("Ex6_14 bt = new Ex6_14(); ");
		Ex6_14 bt = new Ex6_14();

		System.out.println("Ex6_14 bt2 = new Ex6_14(); ");
		Ex6_14 bt2 = new Ex6_14();
	}
}

Ex6_14_result

  • ์ˆœ์„œ
  1. ํด๋ž˜์Šค ์ดˆ๊ธฐํ™” ๋ธ”๋Ÿญ ์ดˆ๊ธฐํ™”
  2. println ์‹คํ–‰
  3. new์—์„œ ์ธ์Šคํ„ด์Šค ์ดˆ๊ธฐํ™” ๋ธ”๋Ÿญ ์ดˆ๊ธฐํ™”
  4. ์ƒ์„ฑ์ž ํ˜ธ์ถœ์— ์ƒ์„ฑ์ž ์ดˆ๊ธฐํ™”
  5. println ์‹คํ–‰
  6. new์—์„œ ์ธ์Šคํ„ด์Šค ์ดˆ๊ธฐํ™” ๋ธ”๋Ÿญ ์ดˆ๊ธฐํ™”
  7. ์ƒ์„ฑ์ž ํ˜ธ์ถœ์— ์ƒ์„ฑ์ž ์ดˆ๊ธฐํ™”

<Ex 2>

class Ex6_15 {
	static int[] arr = new int[10];

	static {
		for(int i=0;i<arr.length;i++) {
			arr[i] = (int)(Math.random()*10) + 1;
		}
	}

	public static void main(String args[]) {
		for(int i=0; i<arr.length;i++)
			System.out.println("arr["+i+"] :" + arr[i]);
	}
}

Ex6_15_result
๋ฐฐ์—ด์ด๋‚˜ ์˜ˆ์™ธ์ฒ˜๋ฆฌ๊ฐ€ ํ•„์š”ํ•œ ์ดˆ๊ธฐํ™”์˜ ๊ฒฝ์šฐ์—๋Š” ๋ช…์‹œ์  ์ดˆ๊ธฐํ™”๋งŒ์œผ๋กœ ๊ฐ€๋Šฅํ•˜์ง€ ์•Š๋‹ค.
๋”ฐ๋ผ์„œ ํด๋ž˜์Šค ์ดˆ๊ธฐํ™” ๋ธ”๋Ÿญ์„ ์ด์šฉํ•˜์—ฌ ์ดˆ๊ธฐํ™” ํ•œ๋‹ค.

  • ์ •๋ฆฌ:
    ๋ช…์‹œ์  ์ดˆ๊ธฐํ™” ์ด์ƒ์˜ ์„ค์ •์ด main์‹คํ–‰์ „์— ์„ธํŒ…๋˜์–ด์•ผ ํ•œ๋‹ค๋ฉด ํด๋ž˜์Šค ์ดˆ๊ธฐํ™” ๋ธ”๋Ÿญ
static{
	//class reset block
}

์„ ํ™œ์šฉํ•ด์„œ ์ดˆ๊ธฐํ™” ํ•ด์ค€๋‹ค.

๐Ÿคทโ€โ™‚๏ธ 6์žฅ ๋

1๊ฐœ์˜ ๋Œ“๊ธ€

comment-user-thumbnail
2023๋…„ 7์›” 18์ผ

๊ธ€ ์ž˜ ๋ดค์Šต๋‹ˆ๋‹ค, ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค.

๋‹ต๊ธ€ ๋‹ฌ๊ธฐ