Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added jaehong/chapter5/"Sample.java"
Empty file.
Empty file added jaehong/chapter5/--help
Empty file.
Empty file added jaehong/chapter5/<classes>
Empty file.
Empty file added jaehong/chapter5/<options>
Empty file.
12 changes: 12 additions & 0 deletions jaehong/chapter5/CompareInteger.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
public class CompareInteger{


public static void main(String...args){

Integer i;
if(i == 42){
System.out.println(42);

}
}
}
Empty file added jaehong/chapter5/Compiled
Empty file.
Binary file added jaehong/chapter5/Direction.class
Binary file not shown.
29 changes: 29 additions & 0 deletions jaehong/chapter5/OperatorCasting.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

public class OperatorCasting{
public static void main(String ...args){
var operator = new OperatorCasting();
operator.casting();
}

public void casting(){

byte byteValue = 127;
short shortValue = byteValue;

shortValue++;
System.out.println(shortValue);

byteValue=(byte)shortValue;

System.out.println(byteValue);

byte s1 = (byte)((int) 9);
byte s2 = (byte)((int) 10);

System.out.println(s1);
System.out.println(s2);
System.out.println(((byte) Long.MAX_VALUE));


}
}
21 changes: 21 additions & 0 deletions jaehong/chapter5/OperatorMultipleDivision.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
public class OperatorMultipleDivision{

public static void main(String...args){

OperatorMultipleDivision sample = new OperatorMultipleDivision();
sample.multipleDivision();
}


public void multipleDivision(){

int intValue1 =5;
int intValue2 =10;

int result = intValue1 * intValue2;
System.out.println(result);
result = intValue2 / intValue1;
System.out.println(result);

}
}
19 changes: 19 additions & 0 deletions jaehong/chapter5/OperatorPlusMinus.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
public class OperatorPlusMinus{

public static void main(String ...args){
OperatorPlusMinus sample = new OperatorPlusMinus();
sample.additive();
}

public void additive(){
int intValue1 = 5;
int intValue2 = 10;

int result=intValue1 + intValue2;

System.out.println(result);
result = intValue2 - intValue1;

System.out.println(result);
}
}
12 changes: 12 additions & 0 deletions jaehong/chapter5/OperatorTilde.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
public class OperatorTilde{

public static void main(String ...args){
int num = 1;
int a = num++ + --num;
System.out.println(a);


final var result = OperatorTilde > OperatorTilde;

}
}
Empty file added jaehong/chapter5/Sample
Empty file.
Binary file added jaehong/chapter5/Sample$1.class
Binary file not shown.
Empty file added jaehong/chapter5/Sample();
Empty file.
Binary file added jaehong/chapter5/Sample.class
Binary file not shown.
42 changes: 42 additions & 0 deletions jaehong/chapter5/Sample.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
public class Sample{

public static void main(String...args){
System.out.println(ifStatement(Direction.TOP));
System.out.println(ifStatement(Direction.BOTTOM));
System.out.println(ifStatement(Direction.LEFT));
System.out.println(ifStatement(Direction.RIGHT));
}

public static int ifStatement(Direction dr){
if(dr == Direction.TOP){
return 1;
}
if(dr == Direction.BOTTOM){
return 2;
}
if(dr == Direction.LEFT){
return 3;
}
if(dr == Direction.RIGHT){
return 4;
}
return 0;
}

public static int switchStatement(Direction dr){
return switch(dr){
case TOP -> 1;
case BOTTOM -> 2;
case LEFT -> 3;
case RIGHT -> 4;
};
}
}


enum Direction{
TOP,
BOTTOM,
LEFT,
RIGHT;
}
Empty file added jaehong/chapter5/Usage:
Empty file.
Binary file added jaehong/chapter5/a
Binary file not shown.
207 changes: 207 additions & 0 deletions jaehong/chapter5/a.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
Classfile /Users/jaehong/Documents/java-basic-1/jaehong/chapter5/Sample.class
Last modified 2023. 4. 17.; size 1046 bytes
SHA-256 checksum 0ed37afb8327701d44e6d0c60e64743dd2622cb7b80a8df03d84081ff0e419f9
Compiled from "Sample.java"
public class Sample
minor version: 0
major version: 62
flags: (0x0021) ACC_PUBLIC, ACC_SUPER
this_class: #20 // Sample
super_class: #2 // java/lang/Object
interfaces: 0, fields: 0, methods: 4, attributes: 3
Constant pool:
#1 = Methodref #2.#3 // java/lang/Object."<init>":()V
#2 = Class #4 // java/lang/Object
#3 = NameAndType #5:#6 // "<init>":()V
#4 = Utf8 java/lang/Object
#5 = Utf8 <init>
#6 = Utf8 ()V
#7 = Fieldref #8.#9 // java/lang/System.out:Ljava/io/PrintStream;
#8 = Class #10 // java/lang/System
#9 = NameAndType #11:#12 // out:Ljava/io/PrintStream;
#10 = Utf8 java/lang/System
#11 = Utf8 out
#12 = Utf8 Ljava/io/PrintStream;
#13 = Fieldref #14.#15 // Direction.TOP:LDirection;
#14 = Class #16 // Direction
#15 = NameAndType #17:#18 // TOP:LDirection;
#16 = Utf8 Direction
#17 = Utf8 TOP
#18 = Utf8 LDirection;
#19 = Methodref #20.#21 // Sample.ifStatement:(LDirection;)I
#20 = Class #22 // Sample
#21 = NameAndType #23:#24 // ifStatement:(LDirection;)I
#22 = Utf8 Sample
#23 = Utf8 ifStatement
#24 = Utf8 (LDirection;)I
#25 = Methodref #26.#27 // java/io/PrintStream.println:(I)V
#26 = Class #28 // java/io/PrintStream
#27 = NameAndType #29:#30 // println:(I)V
#28 = Utf8 java/io/PrintStream
#29 = Utf8 println
#30 = Utf8 (I)V
#31 = Fieldref #14.#32 // Direction.BOTTOM:LDirection;
#32 = NameAndType #33:#18 // BOTTOM:LDirection;
#33 = Utf8 BOTTOM
#34 = Fieldref #14.#35 // Direction.LEFT:LDirection;
#35 = NameAndType #36:#18 // LEFT:LDirection;
#36 = Utf8 LEFT
#37 = Fieldref #14.#38 // Direction.RIGHT:LDirection;
#38 = NameAndType #39:#18 // RIGHT:LDirection;
#39 = Utf8 RIGHT
#40 = Fieldref #41.#42 // Sample$1.$SwitchMap$Direction:[I
#41 = Class #43 // Sample$1
#42 = NameAndType #44:#45 // $SwitchMap$Direction:[I
#43 = Utf8 Sample$1
#44 = Utf8 $SwitchMap$Direction
#45 = Utf8 [I
#46 = Methodref #14.#47 // Direction.ordinal:()I
#47 = NameAndType #48:#49 // ordinal:()I
#48 = Utf8 ordinal
#49 = Utf8 ()I
#50 = Class #51 // java/lang/IncompatibleClassChangeError
#51 = Utf8 java/lang/IncompatibleClassChangeError
#52 = Methodref #50.#3 // java/lang/IncompatibleClassChangeError."<init>":()V
#53 = Utf8 Code
#54 = Utf8 LineNumberTable
#55 = Utf8 main
#56 = Utf8 ([Ljava/lang/String;)V
#57 = Utf8 StackMapTable
#58 = Utf8 switchStatement
#59 = Utf8 SourceFile
#60 = Utf8 Sample.java
#61 = Utf8 NestMembers
#62 = Utf8 InnerClasses
{
public Sample();
descriptor: ()V
flags: (0x0001) ACC_PUBLIC
Code:
stack=1, locals=1, args_size=1
0: aload_0
1: invokespecial #1 // Method java/lang/Object."<init>":()V
4: return
LineNumberTable:
line 1: 0

public static void main(java.lang.String...);
descriptor: ([Ljava/lang/String;)V
flags: (0x0089) ACC_PUBLIC, ACC_STATIC, ACC_VARARGS
Code:
stack=2, locals=1, args_size=1
0: getstatic #7 // Field java/lang/System.out:Ljava/io/PrintStream;
3: getstatic #13 // Field Direction.TOP:LDirection;
6: invokestatic #19 // Method ifStatement:(LDirection;)I
9: invokevirtual #25 // Method java/io/PrintStream.println:(I)V
12: getstatic #7 // Field java/lang/System.out:Ljava/io/PrintStream;
15: getstatic #31 // Field Direction.BOTTOM:LDirection;
18: invokestatic #19 // Method ifStatement:(LDirection;)I
21: invokevirtual #25 // Method java/io/PrintStream.println:(I)V
24: getstatic #7 // Field java/lang/System.out:Ljava/io/PrintStream;
27: getstatic #34 // Field Direction.LEFT:LDirection;
30: invokestatic #19 // Method ifStatement:(LDirection;)I
33: invokevirtual #25 // Method java/io/PrintStream.println:(I)V
36: getstatic #7 // Field java/lang/System.out:Ljava/io/PrintStream;
39: getstatic #37 // Field Direction.RIGHT:LDirection;
42: invokestatic #19 // Method ifStatement:(LDirection;)I
45: invokevirtual #25 // Method java/io/PrintStream.println:(I)V
48: return
LineNumberTable:
line 4: 0
line 5: 12
line 6: 24
line 7: 36
line 8: 48

public static int ifStatement(Direction);
descriptor: (LDirection;)I
flags: (0x0009) ACC_PUBLIC, ACC_STATIC
Code:
stack=2, locals=1, args_size=1
0: aload_0
1: getstatic #13 // Field Direction.TOP:LDirection;
4: if_acmpne 9
7: iconst_1
8: ireturn
9: aload_0
10: getstatic #31 // Field Direction.BOTTOM:LDirection;
13: if_acmpne 18
16: iconst_2
17: ireturn
18: aload_0
19: getstatic #34 // Field Direction.LEFT:LDirection;
22: if_acmpne 27
25: iconst_3
26: ireturn
27: aload_0
28: getstatic #37 // Field Direction.RIGHT:LDirection;
31: if_acmpne 36
34: iconst_4
35: ireturn
36: iconst_0
37: ireturn
LineNumberTable:
line 11: 0
line 12: 7
line 14: 9
line 15: 16
line 17: 18
line 18: 25
line 20: 27
line 21: 34
line 23: 36
StackMapTable: number_of_entries = 4
frame_type = 9 /* same */
frame_type = 8 /* same */
frame_type = 8 /* same */
frame_type = 8 /* same */

public static int switchStatement(Direction);
descriptor: (LDirection;)I
flags: (0x0009) ACC_PUBLIC, ACC_STATIC
Code:
stack=2, locals=1, args_size=1
0: getstatic #40 // Field Sample$1.$SwitchMap$Direction:[I
3: aload_0
4: invokevirtual #46 // Method Direction.ordinal:()I
7: iaload
8: tableswitch { // 1 to 4
1: 48
2: 52
3: 56
4: 60
default: 40
}
40: new #50 // class java/lang/IncompatibleClassChangeError
43: dup
44: invokespecial #52 // Method java/lang/IncompatibleClassChangeError."<init>":()V
47: athrow
48: iconst_1
49: goto 61
52: iconst_2
53: goto 61
56: iconst_3
57: goto 61
60: iconst_4
61: ireturn
LineNumberTable:
line 27: 0
line 28: 48
line 29: 52
line 30: 56
line 31: 60
line 27: 61
StackMapTable: number_of_entries = 6
frame_type = 40 /* same */
frame_type = 7 /* same */
frame_type = 3 /* same */
frame_type = 3 /* same */
frame_type = 3 /* same */
frame_type = 64 /* same_locals_1_stack_item */
stack = [ int ]
}
SourceFile: "Sample.java"
NestMembers:
Sample$1
InnerClasses:
static #41; // class Sample$1
Empty file added jaehong/chapter5/class
Empty file.
Empty file added jaehong/chapter5/for
Empty file.
Empty file added jaehong/chapter5/from
Empty file.
Empty file.
Empty file added jaehong/chapter5/int
Empty file.
Binary file added jaehong/chapter5/javap
Binary file not shown.
Empty file added jaehong/chapter5/list
Empty file.
Empty file.
Empty file added jaehong/chapter5/of
Empty file.
Empty file added jaehong/chapter5/options
Empty file.
Empty file added jaehong/chapter5/possible
Empty file.
Empty file added jaehong/chapter5/public
Empty file.
Empty file added jaehong/chapter5/static
Empty file.
Empty file.
19 changes: 19 additions & 0 deletions jaehong/chapter5/untitled/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
plugins {
id 'java'
}

group 'org.example'
version '1.0-SNAPSHOT'

repositories {
mavenCentral()
}

dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
}

test {
useJUnitPlatform()
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading