File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed
src/main/java/practiceJAVA Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change 1+ package practiceJAVA ;
2+
3+ public class Car {
4+ String company = "ferrari" ;
5+ String color ;
6+ int maxSpeed ;
7+
8+ // this μ κΈ°λ°μ΄ λ 곡ν΅λΆλΆμ΄ λ§μ μμ±μ. π΄ this μ¬μ© μ, μ΄ κ³΅ν΅ μμ±μμ λ§€κ°λ³μ μμλ₯Ό μ§μΌμΌν¨.
9+ Car (String color , int maxSpeed ) {
10+ this .color = color ;
11+ this .maxSpeed = maxSpeed ;
12+ }
13+
14+ Car (String color ) {
15+ // κ³΅ν΅ μμ±μ νΈμΆ
16+ this (color , 100000 );
17+ }
18+ Car (int maxSpeed ) {
19+ // κ³΅ν΅ μμ±μ νΈμΆ
20+ this ("red" , maxSpeed );
21+ // this(maxSpeed, "red") [x] -> 곡ν΅μμ±μμ λ§€κ°λ³μ μμκ° λ€λ¦.
22+ }
23+ }
Original file line number Diff line number Diff line change 1+ package practiceJAVA ;
2+
3+ /**
4+ * μμ±μ μ€λ²λ‘λ©μ ν΅ν΄ μ½λ μ€λ³΅μ΄ λ§μμ§λ κ²½μ°λ₯Ό μ μ΄ κ°λ₯ν κΈ°λ₯
5+ * this
6+ */
7+
8+
9+ public class ThisOfConstructor {
10+ public static void main (String [] args ) {
11+
12+ Car newCar1 = new Car ("red" );
13+ System .out .println (newCar1 .maxSpeed );
14+
15+ }
16+ }
You canβt perform that action at this time.
0 commit comments