From fe4d448caf11719f57aeee110f57bb7b70899809 Mon Sep 17 00:00:00 2001 From: JaeHong Jeong Date: Mon, 13 Mar 2023 22:41:41 +0900 Subject: [PATCH 1/8] Update README.md --- README.md | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 4f60f5c..465f795 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,6 @@ -# GodOfJava 2nd Edition -자바의신 코드 저장소 입니다. - -# 예제 실행기 다운로드 -상단의 메뉴에서 "Release" 를 클릭하면 파일을 다운로드 할 수 있습니다. - -# 연습문제 답 -연습문제의 답은 각 챕터의 링크를 따라가면 확인할 수 있습니다. -예) Chapter01/src 디렉터리로 이동하면 Calculator.java 파일의 소스를 보실 수 있습니다. - -# 질문은 자바의 신 카페에~~~ -질문은 자바의 신 카페에서 해 주시기 바랍니다. - -http://cafe.naver.com/godofjava.cafe \ No newline at end of file +### CHOCO-CHANEL'S JAVA STUDY LOGS +* Reference +```python +# Fork: GodOfJava 2nd Edition +# 자바의신 코드 저장소 +``` From 4c242c3c2406f2f549b1810124999c82d82426e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=5BSW2/=EC=84=9C=EC=9A=B8/1=EB=B0=98=5D=20=EC=A0=95?= =?UTF-8?q?=EC=9E=AC=ED=99=8D?= Date: Mon, 13 Mar 2023 23:30:47 +0900 Subject: [PATCH 2/8] Make class of my own Calculator and its implementation class file. --- Chapter01/src/Calculator.java | 15 +++-- Chapter01/src/MyCalculator.java | 30 +++++++++ Chapter01/src/MyCalculatorImpl.java | 60 ++++++++++++++++++ out/production/Chapter01/Calculator.class | Bin 0 -> 875 bytes out/production/Chapter01/MyCalculator.class | Bin 0 -> 1280 bytes .../Chapter01/MyCalculatorImpl.class | Bin 0 -> 1852 bytes 6 files changed, 98 insertions(+), 7 deletions(-) create mode 100644 Chapter01/src/MyCalculator.java create mode 100644 Chapter01/src/MyCalculatorImpl.java create mode 100644 out/production/Chapter01/Calculator.class create mode 100644 out/production/Chapter01/MyCalculator.class create mode 100644 out/production/Chapter01/MyCalculatorImpl.class diff --git a/Chapter01/src/Calculator.java b/Chapter01/src/Calculator.java index 84b0b6d..f255ff2 100644 --- a/Chapter01/src/Calculator.java +++ b/Chapter01/src/Calculator.java @@ -1,27 +1,28 @@ public class Calculator { - + + public int sum = 0; + public int result; + public int add(int num1, int num2) { - int sum; sum = num1 + num2; return sum; } public int addAll(int num1, int num2, int num3) { - int sum=0; - // Insert code here. + sum = num1 + num2 + num3; return sum; } public int subtract(int num1, int num2) { - int result=num1 - num2; + result = num1 - num2; return result; } public int multiply(int num1, int num2) { - int result=num1 * num2; + result = num1 * num2; return result; } public int divide(int num1, int num2) { - int result=num1 / num2; + result = num1 / num2; return result; } diff --git a/Chapter01/src/MyCalculator.java b/Chapter01/src/MyCalculator.java new file mode 100644 index 0000000..6784608 --- /dev/null +++ b/Chapter01/src/MyCalculator.java @@ -0,0 +1,30 @@ +public class MyCalculator { + + public int add(int a, int b) { + System.out.printf("%d + %d = %d", a, b, a + b); + System.out.println(); + return a + b; + } + + public int subtract(int a, int b) { + System.out.printf("%d - %d = %d", a, b, a - b); + System.out.println(); + return a - b; + } + + public int multiply(int a, int b) { + System.out.printf("%d * %d = %d", a, b, a * b); + System.out.println(); + return a * b; + } + + public int divide(int a, int b) { + if (b == 0) { + System.out.println("Error: Divided By Zero"); + return -1; // unexpected error + } + System.out.printf("%d / %d = %d", a, b, a / b); + System.out.println(); + return a / b; + } +} diff --git a/Chapter01/src/MyCalculatorImpl.java b/Chapter01/src/MyCalculatorImpl.java new file mode 100644 index 0000000..1d2e054 --- /dev/null +++ b/Chapter01/src/MyCalculatorImpl.java @@ -0,0 +1,60 @@ +import java.util.Scanner; + +public class MyCalculatorImpl { + + public static void showMenu() { + System.out.println("======= Menu ======="); + System.out.println("0. Exit"); + System.out.println("1. Add"); + System.out.println("2. Subtract"); + System.out.println("3. Multiply"); + System.out.println("4. Divide"); + System.out.println("Please put the command number:"); + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + MyCalculator myCalculator = new MyCalculator(); + boolean flag = true; + int command = 0; + int a = 0; + int b = 0; + while (flag) { + showMenu(); + command = sc.nextInt(); + switch (command) { + case 0: + flag = false; + System.out.println("Thanks. See you later :)"); + break; + case 1: + System.out.println("Put a, b that you want to add: "); + a = sc.nextInt(); + b = sc.nextInt(); + myCalculator.add(a, b); + break; + case 2: + System.out.println("Put a, b that you want to subtract: "); + a = sc.nextInt(); + b = sc.nextInt(); + myCalculator.subtract(a, b); + break; + case 3: + System.out.println("Put a, b that you want to multiply: "); + a = sc.nextInt(); + b = sc.nextInt(); + myCalculator.multiply(a, b); + break; + case 4: + System.out.println("Put a, b that you want to divide: "); + a = sc.nextInt(); + b = sc.nextInt(); + myCalculator.divide(a, b); + break; + default: + System.out.println("You got an wrong number. Please try again."); + break; + } + } + } +} diff --git a/out/production/Chapter01/Calculator.class b/out/production/Chapter01/Calculator.class new file mode 100644 index 0000000000000000000000000000000000000000..e9f646a382f81e57b8845f69847ac56e175ceaff GIT binary patch literal 875 zcma)(PfO!a6vfYL(xzr&t5xgxcj`{FP(~LsFvEZdLZLW|5f`p}O@e*pwH?w#@H@E? zMg$jrfca1|=cSnzq=jx??z{Kg-?{hY@7v2OfG^l{QN;EFZ0wk0*TE+T4FPMI_5?&z zpcF^LR3{9+tG-Hpu(p42C19To!bqUnQvK*6?X{!$QnocSwbmez`bx&i-1DTJbktD5 zYn@3Qq*^9}_!~(w3&&5PNshA zd#XZpr_4a^uR$6I(YZ3SR3~pM65We+h!Vbus(H%@Cg=ou-@;m%&ywpJA9nV?#y7XkzJpgy)l)o QXRtTO-kh7gnfF5SSzHQpZOMlQc+}FHoQDnC5 z^tiRdT~pknpyc(K3>6>f7CYqvy%Er{X>y$atvIz}8eeMm{WC8I=i@>gYQE+;tsyU3(TF z>e|LoduzCks9g_h>!W0K9PuB5&hXGP1~eMSr*A*s4%kem{>n9Nuj9D}AJE_mBjlFt z8GDAyARlqdH?}`8%$Hl0urTSfw{jdx?Aa5{}h`#&f- z(6Ma7juEQt(2L8`(-XfG=rtfuc7|?sI+=)8zkz)rCxHUlbP%K`MZOv)U=HW#MjbFu zRup@Xk)*Ts6^Yqo`X{8_Wbr#von5IE9I0aIy>L#DenUAYkSTCX6=9cLP%UARpsLhU zbkjn`s2geH0xkvwHC!SuLHp1Q{ZjCIa=$1jTrQsd$3^Btd_YV1@_^ zL@;}1g3>9$r)Ue!(r0AFCNd|OP8w5TiOCUEsH#~$Mq literal 0 HcmV?d00001 diff --git a/out/production/Chapter01/MyCalculatorImpl.class b/out/production/Chapter01/MyCalculatorImpl.class new file mode 100644 index 0000000000000000000000000000000000000000..60a00a5719f1b715a7b214734348adae2e89e944 GIT binary patch literal 1852 zcmah~&2Jk;6#q^9u^Zb-^X1efBw5k|Nt)V8o2L0_10`vxA#Ot*Qj$_&Y;T=y*6U!e zn+Ay+oVWltkhp;&!G-qFpjL2#10W$GAr44zLxO*z;Wz6obx|rtnt3zty?GzM_h$Ep zdw0G8Z~|8&=*46+rZBBzCW4bVrDImdGdiBtaazZ7I_5OYD~&S|L~&Nb^AWUSGJ?l( zPI1yYUeNKPVlL>&D0*JU1w|Kiyrk$w9a#-a8eSF%pR^pyofQZS4lN4==gI|BVBdn} znCEMyoLO0tIh&l0g>qin%d%prv(F5=YgSdsGFx-f&ev?|mMiJfhCL&oSJ%p$8PloJ zXh~X*K=B%?C7zik*V3PwP9}wG><2ZdF#5Rs?fJ+o3d&e8#UK(*G$9D!En67ObfJoa5kb6 z!>hQW0(_0|G)5o8ljx7(b-W>vSXz_LdX+(#rmu(D z>=b=el7mI`Km8nyCuWz{+k_U9-eTQLa%CuXmqSPA#%$ zU3RW1OYE;s&&I=S7JNe~*=+du;NJb-q+Y`VqiKf){?};2zeKZ*0`*Qb$GqXD9Y(~* z$~F$LBm$wqbXuMC`^a;9A6PbB9XC9|??W%YF+c$9EcA0VcuJ89($Me@#7%CRs0xHV zW&i`+$Lb0=h(kOzt41Qn;J!p{HKuN%sUvV3K}AD84f|B{sqWKepGHWPL*Y3bfX;oG ztA;kN2|6+m!5}|rqYPmZE#y3fr|Yi8J?5eD#@}}lUAcwW4q6uOqIG2l`!d1Vz(g=G z5eiI%dq2YWU!m>rZM07Won`a_ij> zd24ti9*Q%!u1njypDKBLZ+SQ6?Pq!Y91>8Ak90j^HMexWgv-8e{klNAV+$;b)BFHyp?B{9*mc!u*99uTRd^ z3qmVHj5UfsFicB)Cis=sj<8qa_=WaT%p*Z7qqG@hd_U3d7($F)Ss!B)jPrgk^j)$v Y4aYS^HM9y2U@X?p5uw=$DmCH6Kb>irG5`Po literal 0 HcmV?d00001 From dce90a0cb81733d9160c916cff9cb5475bc2692a Mon Sep 17 00:00:00 2001 From: CHOCOCHANEL Date: Tue, 14 Mar 2023 10:21:18 +0900 Subject: [PATCH 3/8] test git commit --- Chapter01/src/MyCalculatorImpl.java | 1 + 1 file changed, 1 insertion(+) diff --git a/Chapter01/src/MyCalculatorImpl.java b/Chapter01/src/MyCalculatorImpl.java index 1d2e054..f688241 100644 --- a/Chapter01/src/MyCalculatorImpl.java +++ b/Chapter01/src/MyCalculatorImpl.java @@ -21,6 +21,7 @@ public static void main(String[] args) { int b = 0; while (flag) { showMenu(); + System.out.println("git commit 테스트"); command = sc.nextInt(); switch (command) { case 0: From b3d55644807758511fdd326800e0881e1abf4600 Mon Sep 17 00:00:00 2001 From: CHOCOCHANEL Date: Tue, 14 Mar 2023 10:27:02 +0900 Subject: [PATCH 4/8] =?UTF-8?q?git=20commit=20=ED=85=8C=EC=8A=A4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Chapter01/src/MyCalculatorImpl.java | 1 - 1 file changed, 1 deletion(-) diff --git a/Chapter01/src/MyCalculatorImpl.java b/Chapter01/src/MyCalculatorImpl.java index f688241..1d2e054 100644 --- a/Chapter01/src/MyCalculatorImpl.java +++ b/Chapter01/src/MyCalculatorImpl.java @@ -21,7 +21,6 @@ public static void main(String[] args) { int b = 0; while (flag) { showMenu(); - System.out.println("git commit 테스트"); command = sc.nextInt(); switch (command) { case 0: From 8d7286100e328106c411d414267444a9f5338044 Mon Sep 17 00:00:00 2001 From: CHOCOCHANEL Date: Wed, 22 Mar 2023 22:04:30 +0900 Subject: [PATCH 5/8] Chapter2. class and method - 20230322 --- Chapter02/src/MyProfile.java | 41 +++++++++++++++++++ Chapter02/src/MyProfileImpl.java | 6 +++ out/production/Chapter02/MyProfile.class | Bin 0 -> 1550 bytes out/production/Chapter02/MyProfileImpl.class | Bin 0 -> 642 bytes out/production/Chapter02/Profile.class | Bin 0 -> 1122 bytes 5 files changed, 47 insertions(+) create mode 100644 Chapter02/src/MyProfile.java create mode 100644 Chapter02/src/MyProfileImpl.java create mode 100644 out/production/Chapter02/MyProfile.class create mode 100644 out/production/Chapter02/MyProfileImpl.class create mode 100644 out/production/Chapter02/Profile.class diff --git a/Chapter02/src/MyProfile.java b/Chapter02/src/MyProfile.java new file mode 100644 index 0000000..05967f2 --- /dev/null +++ b/Chapter02/src/MyProfile.java @@ -0,0 +1,41 @@ +public class MyProfile { + private String name = ""; + private int age = -1; + + public MyProfile(String name) { + this.name = name; + } + + public MyProfile(int age) { + this.age = age; + } + + public MyProfile(String name, int age) { + this.name = name; + this.age = age; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } + + @Override + public String toString() { + return "MyProfile{" + + "name='" + name + '\'' + + ", age=" + age + + '}'; + } +} diff --git a/Chapter02/src/MyProfileImpl.java b/Chapter02/src/MyProfileImpl.java new file mode 100644 index 0000000..65d5938 --- /dev/null +++ b/Chapter02/src/MyProfileImpl.java @@ -0,0 +1,6 @@ +public class MyProfileImpl { + public static void main(String[] args) { + MyProfile profile = new MyProfile("choco-chanel", 25); + System.out.println(profile); + } +} diff --git a/out/production/Chapter02/MyProfile.class b/out/production/Chapter02/MyProfile.class new file mode 100644 index 0000000000000000000000000000000000000000..ef945eccd976b136ba836e4ae2f7417c41a4e47d GIT binary patch literal 1550 zcmah}YfsZ)7(MSc)~(D9xjRsX4tD{WcT6TEx`aqF&;)`pek!AmLTO1`NQm)&_#^zF ziN=Hv{s4cJ@w{#61{<2C@Ac_9=Q&TG{r+?I3&0YVR4BNW!b}=T6yz{F%!@e%cNLTb z5|(zT3k)~+wG*voYF4|p={bhgt_#GqHm}5*K=Qd^8QzM(Sh+W_vQ3zVz025K)3Ef7 z|W zwU%c)rwX3XpQdde93Kf})+|eR8m8vDIypagbA}i}_OCQ+*VNr&@M67JM%T%O7q?E2 z^giM5yW#`S>fI#{AsU)#ZW^9mSMXF|t|z~K+5~R>I}Wq#356{YLcU)%)#(ddd8PpR&`Bvvt{iTV zO{P@{kfOBmVOm6&%|j;sanP8+#~Nog7Y3@|5&z0Xj8GtjJRI=>GeJNI$hL@zu)=8R zVe*pes((5`-zU2)NJf&9k<*iu-76&V<&u!8zC!X*nL0u))+G=!Lm`DLgq+u6Dsto* w#mnTg(h)w1Gx-f&wx-ynC>tgg$F#5eCLVHDiEPeqR&}f~B#)#kgJXtx zxzb|LPP|*eFjbeXxad1=;a~B#O_^NXv$);jzEtr~QVY7Wr_kq54d1(ywm5Sh>>ANH zT)GU!@=g7oKk};0-A=U`_|omvLK*INs4@RfnL&SuxEL}cVj?w~Uf;LGDap`0za$To ziitD~hV-z)U|LpC_}Y+_5twuv2-8778!H9SLhH1TEoURZ(h@z=(g z@-c>OKJ^0O&>p=$brhlo=~WwKIw0$UJLDlBlK)PJjtOMb#tP#~kvuI7YtZRWsxJm| z2!qZHMOC^P-HF`+*mGDm=}d-6vPN$+0$>tT6s3{HG-XtC0~*l*Gw+C9=i=GY09yS8 niM>}OM_iML6DCeP8uCbloW-aQIm#%76lPE$R@xNBG0c7g1lNef literal 0 HcmV?d00001 diff --git a/out/production/Chapter02/Profile.class b/out/production/Chapter02/Profile.class new file mode 100644 index 0000000000000000000000000000000000000000..4532f6ceb9724260a161176144432da914c0a0d1 GIT binary patch literal 1122 zcmaJ=+fEZf82*MHwk<1Qv7mCWC}IJno>3RLpb3$rSdtRF@M&TGBa|z8&g`F|E(+KpD<)y4T(rs6p+PB@d6%~+vn<>*H+)Q?5C#p4+N`A6Um)I95 zG`*hRQhO{YU?!zE!W0vE6d2lQGz?TstYS@IYS;60pncgrQ2NX}4JNZ#&*7 Date: Wed, 29 Mar 2023 07:04:07 +0900 Subject: [PATCH 6/8] Up-to-date README.md --- README.md | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 465f795..c06de46 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,38 @@ ### CHOCO-CHANEL'S JAVA STUDY LOGS -* Reference +##### Reference ```python # Fork: GodOfJava 2nd Edition # 자바의신 코드 저장소 ``` + +##### Logs +* 01 Programming +> Class & Method
+> - A class is the minimum unit of java consisting of state and behavior. +> - A method receives the parameter and returns the calculation result.
+ +* 02 Hello God Of Java + > Building a development Environment + > - Compilation of Java File
+ > - Printing on the console
+ > - Comment
+```java +public class Sample { + public static void main(String[] args){ + System.out.println("Printing on the console."); + } +} +``` + +* 03 Object Oriented Programming +> Concept of Object +> - An object is an instance of a class.
+> - A class consists of variables and methods.
+```java +public class Calculator { + public static void main(String[] args) { + System.out.println("Constructor"); + Calculator myCalculator = new Calculator(); + } +} +``` \ No newline at end of file From 8e79fff44ad52e93835e3854d600ea41b71be01f Mon Sep 17 00:00:00 2001 From: CHOCOCHANEL Date: Wed, 29 Mar 2023 07:08:26 +0900 Subject: [PATCH 7/8] Chapter3. Object Oriented Programming - 20230328 --- Chapter03/src/MyProfile.java | 28 +++++++++++++++++++++++ out/production/Chapter03/MyProfile.class | Bin 0 -> 1645 bytes out/production/Chapter03/Profile.class | Bin 0 -> 1601 bytes 3 files changed, 28 insertions(+) create mode 100644 Chapter03/src/MyProfile.java create mode 100644 out/production/Chapter03/MyProfile.class create mode 100644 out/production/Chapter03/Profile.class diff --git a/Chapter03/src/MyProfile.java b/Chapter03/src/MyProfile.java new file mode 100644 index 0000000..85f8e66 --- /dev/null +++ b/Chapter03/src/MyProfile.java @@ -0,0 +1,28 @@ +public class MyProfile { + String name = "default"; + int age = 0; + + public static void main(String[] args) { + Profile profile = new Profile(); + profile.setName("choco-chanel"); + profile.setAge(25); + profile.printName(); + profile.printAge(); + } + + public void setName(String str) { + name = str; + } + + public void setAge(int value) { + age = value; + } + + public void printName() { + System.out.println("My name is " + name); + } + + public void printAge() { + System.out.println("My age is " + age); + } +} \ No newline at end of file diff --git a/out/production/Chapter03/MyProfile.class b/out/production/Chapter03/MyProfile.class new file mode 100644 index 0000000000000000000000000000000000000000..fcca328dd8719dd0acc443545dfbc50a4b052fb8 GIT binary patch literal 1645 zcmaJ>?Q+vb6g?X|maV8xa7YYEfzSppHjtKnf@xafHYLRg0f(>Q*Tz|55n1v`a%TJ{ zeT^~@X2J{)(1+^utfavXR{KL&d++W&_uP-&zyCS@0N@8aGjR&n^SDvK3|6%G%D~qq zCbjXV{(qyzw_1Fs#rFkz{aB*&9TPucwFH4*4BR!aCXjVyR|%AwujHXzaiqJy(h7as z-LDH|DyXQjM=bb z2Le;g&B3}*%suE2cd#dzc>g!K36G@G(5VDw@ffkJZ#X#^_Vin5ujq=ROH z&}T9{cUNbYt!(H}lZVpjQ!VtEcY=_Q*3l`m<@NoxS|@LT;>R3r=z>|8N11%~)JxfS zLJK9#S~!h4+7e;{R=eZ1z3c6cbd_V_ODtQsj4KwdqHLjxvVn$$U-6s3%$nzgBq@8F zD(rZB!E_GmdHinS9ySd8Vc|ZO^Jr>)lZ-#Iq3f`L4|ZRvc6h?n8U&&0vVUHm8*_1a zY;R>-r_6>c*{z${!UNLX94zUfSh9m9AyDqh1J&@{whW)zVTY?Aly1o0Tu!UWBL+?N(0~>Q(m+jE=2L{;KT+{Oo z`aPz!;kwFiI5G$niT^oDJi&O(_q9f%2qSAT5)yQ&FJ#7z`J%#B+Hja1mcHl+YI`3Avht z%vEb-Kg2d8-y+|@=@G14LRv??#KLGS-p4Vl#S=w{u}Z|6{ST}PxoIq3>k+J|w69@R z-yn00&wwKoKV>*ie&v+13jI2yV`Y!&lZLfG`(g@K1~t}i0@u*u-z4foJjNq7_!jjd McW%>GkL1t)0`w74EdT%j literal 0 HcmV?d00001 diff --git a/out/production/Chapter03/Profile.class b/out/production/Chapter03/Profile.class new file mode 100644 index 0000000000000000000000000000000000000000..bcc7acb969c4b9d3b6f0feb3ed20da42e26c4a49 GIT binary patch literal 1601 zcmaJ>e^VP(6g`iGY_hC@rX;jQT8e;aVvANQYLFJvV$p=4!8(qAJ;Ez&+3aR^H_Y%& z{2Dp}GjygOzz^kk-tNv2Oza-YmIrrZ8_V0f#-vL;~&nBi&&Ek_B#_>>_M+R0* zj@(h4ck>a{qDZ<_vF44!FV0%ypq1H*U4r&JhB6U zTw~YwUfYf$a=I&RSD;k>ZJ0MAkp3YFnTc#XMqZLBK^hkXrNRO`jk(<4V_E6 zyshEKPo&f5GS_3K2|_lSM_y*z>-!zGMXdr>qWY08kcA>jtU{~RvTy?h3pX)M9f=Q5 znzn1F4QvWbZF*ivRkGJq;gNR`OlDBe;<<$v*fQ{)g_l^! zVq34jr~6f3TKjKQC%m@RJ`FyBCWGD3eQv+>wv*CHi{T@@=c3tJy9T^0Q!hatWo?yf^ekt7p zM+J*Ob4wuV(s9~$sA>lG1eS*K8>LO)?)&|Cx5oMS zfiZr(fwa(Ko5tU*v+{HcmWhs1~l>FQ1$CFU5CzP2=mFlms%_ug{LQD=|WfIYv^&=KWWAP0R zVa;AELX35TScU(=TBdf5#iu-g6_xf+Se3t!y2J;-Ir9HiI8A-U5oHznk1!f5eaVpV}s;@;Ph{q|qA%R$Eg literal 0 HcmV?d00001 From baa9f5b7a68286c591e09a116c137f7d4bcad6ed Mon Sep 17 00:00:00 2001 From: CHOCOCHANEL Date: Wed, 5 Apr 2023 22:00:51 +0900 Subject: [PATCH 8/8] 20230405 Variables of Java --- Chapter04/src/JavaVariables.java | 16 ++++++++++++++++ README.md | 20 ++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 Chapter04/src/JavaVariables.java diff --git a/Chapter04/src/JavaVariables.java b/Chapter04/src/JavaVariables.java new file mode 100644 index 0000000..a2f8924 --- /dev/null +++ b/Chapter04/src/JavaVariables.java @@ -0,0 +1,16 @@ +public class JavaVariables { + private int instanceVariable; + + private static int classVariable; + + public void method(String[] parameters) { + int localVariable = this.instanceVariable; + } + + public static void main(String[] args) { + System.out.println("Java의 변수는 총 4가지가 있다."); + System.out.println("1) 클래스 변수 vs 2) 인스턴스 변수"); + System.out.println("3) Parameter vs 4) 지역 변수"); + System.out.println("각 변수는 생명주기와 용도가 다르다"); + } +} diff --git a/README.md b/README.md index c06de46..7478ecd 100644 --- a/README.md +++ b/README.md @@ -35,4 +35,24 @@ public class Calculator { Calculator myCalculator = new Calculator(); } } +``` + +* 04 Data Type +> Variables of Java +> - Java has 4 types of variables and each of them has different range of scope and usability.
+```python +# === 4 Types of Variables === +1. Local variables +2. Parameters +3. Instance Variables +4. Class Variables +``` +> Data Types +> - Primitive Data Type vs Reference Data Type +```python +# === 4 Types of Variables === +1. Local variables +2. Parameters +3. Instance Variables +4. Class Variables ``` \ No newline at end of file