Skip to content

Commit fe78e4c

Browse files
401ST-012401ST-012
authored andcommitted
ch04
1 parent 4225d91 commit fe78e4c

16 files changed

Lines changed: 401 additions & 0 deletions

‎ch04/.classpath‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-10">
4+
<attributes>
5+
<attribute name="module" value="true"/>
6+
</attributes>
7+
</classpathentry>
8+
<classpathentry kind="src" path="src"/>
9+
<classpathentry kind="output" path="bin"/>
10+
</classpath>

‎ch04/.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/bin/

‎ch04/.project‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>ch04</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.jdt.core.javanature</nature>
16+
</natures>
17+
</projectDescription>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=10
4+
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5+
org.eclipse.jdt.core.compiler.compliance=10
6+
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7+
org.eclipse.jdt.core.compiler.debug.localVariable=generate
8+
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
11+
org.eclipse.jdt.core.compiler.release=enabled
12+
org.eclipse.jdt.core.compiler.source=10
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package challenge;
2+
3+
public class PrinterTest {
4+
5+
public static void main(String[] args) {
6+
// TODO Auto-generated method stub
7+
Printer printerC = new Printer();
8+
printerC.numOfPapers =printerC.numOfPapers + 100;
9+
printerC.print(70);
10+
System.out.println(printerC.numOfPapers);
11+
}
12+
13+
}
14+
15+
class Printer{
16+
int numOfPapers;
17+
18+
void print(int amount) {
19+
20+
}
21+
22+
23+
}
24+
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package challenge;
2+
3+
public class PrinterTest2 {
4+
5+
public static void main(String[] args) {
6+
// TODO Auto-generated method stub
7+
Printer2 printerC = new Printer2();
8+
// printerC.numOfPapers =printerC.numOfPapers + 100;
9+
printerC.print(70);
10+
// System.out.println(printerC.numOfPapers);
11+
}
12+
13+
}
14+
15+
class Printer2{
16+
private int numOfPapers;
17+
boolean lack;
18+
void print(int amount) {
19+
20+
21+
22+
23+
24+
25+
}
26+
27+
public int getNumOfPapers() {
28+
return numOfPapers;
29+
}
30+
31+
public Printer2(){
32+
numOfPapers = 0;
33+
}
34+
35+
public Printer2(int x) {
36+
numOfPapers =x;
37+
}
38+
39+
40+
41+
}
42+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package example;
2+
3+
public class _4_10_CircleDemo {
4+
5+
public static void main(String[] args) {
6+
// TODO Auto-generated method stub
7+
_4_10_Circle myCircle = new _4_10_Circle(10.0);
8+
_4_10_Circle yourCircle = new _4_10_Circle(5.0);
9+
10+
System.out.println("원의 개수 : " + _4_10_Circle.numOfCircles);
11+
System.out.println("원의 개수 : " + yourCircle.numCircles);
12+
}
13+
14+
void print() {
15+
System.out.println("정적 멤버에 대한 내용입니다.");
16+
}
17+
18+
}
19+
20+
class _4_10_Circle {
21+
double radius;
22+
static int numOfCircles = 0;
23+
int numCircles = 0;
24+
25+
public _4_10_Circle(double radius) {
26+
27+
this.radius = radius;
28+
numOfCircles++;
29+
numCircles++;
30+
}
31+
32+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package example;
2+
3+
class Util{
4+
static int fourTimes(int i) {
5+
return i * 4;
6+
}
7+
}
8+
9+
public class _4_11_UtilDemo {
10+
11+
public static void main(String[] args) {
12+
// TODO Auto-generated method stub
13+
System.out.println(Util.fourTimes(5));
14+
}
15+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package example;
2+
3+
public class _4_12_OneToTenDemo {
4+
static int sumOneToTen;
5+
6+
static {
7+
int sum = 0;
8+
for( int i =1; i <= 10; i++)
9+
sum += i;
10+
sumOneToTen = sum;
11+
}
12+
13+
14+
public static void main(String[] args) {
15+
// TODO Auto-generated method stub
16+
System.out.println(sumOneToTen);
17+
}
18+
19+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package example;
2+
3+
4+
5+
public class _4_1PhoneDemo {
6+
public static void main(String[] args) {
7+
Phone myPhone = new Phone();
8+
myPhone.model = "갤럭시 S8";
9+
myPhone.value = 100;
10+
myPhone.print();
11+
12+
//new 힙 메모리에 할당
13+
Phone yourPhone = new Phone();
14+
15+
yourPhone.model = "G6";
16+
yourPhone.value = 85;
17+
yourPhone.print();
18+
19+
}
20+
}
21+
22+
class Phone {
23+
24+
String model;
25+
int value;
26+
void print() {
27+
// this.value "this."이 생략되어 있음
28+
System.out.println(value + "만원 짜리 "+ model +" 스마트폰");
29+
30+
}
31+
32+
}
33+

0 commit comments

Comments
 (0)