Last active
September 11, 2020 13:56
-
-
Save JoeUnsung/0b7f7b4e99e76c70ec7c2985a85cbacc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Java의 정석 예제 | |
// 2-4 | |
package playGround; | |
public class testJava { | |
public static void main(String[] args) { | |
byte b = 1; | |
short s = 2; | |
char c = 'A'; | |
int finger = 10; | |
long big = 100_000_000_00L; // long big = 10000000000L | |
long hex = 0xFFFF_FFFF_FFFF_FFFFL; | |
int octNum = 010; | |
int hexNum = 0x10; | |
int binNum = 0b10; | |
System.out.printf("b = %d%n", b); | |
System.out.printf("s = %d%n", s); | |
System.out.printf("c = %s%n", c); | |
System.out.printf("finger = [%5d]%n", finger*100); | |
System.out.printf("finger = [%-5d]%n", finger); | |
System.out.printf("finger = [%05d]%n", finger); | |
System.out.printf("big = %d%n", big); | |
System.out.printf("hex = %x%n", hex); | |
System.out.printf("octNum = %o, %d%n", octNum, octNum); | |
System.out.printf("hexNum = %x, %d%n", hexNum, hexNum); | |
System.out.printf("binNum = %s, %d%n", binNum, binNum); | |
} | |
} | |
// 2-5 | |
package playGround; | |
import java.util.*; | |
public class testJava { | |
public static void main(String[] args) { | |
Scanner scanner = new Scanner(System.in); | |
System.out.print("두 자리 정수를 하나 입력해주세요."); | |
int num = Integer.parseInt(scanner.nextLine()); | |
System.out.println("입력내용 : "+num); | |
System.out.printf("num=%d%n", num); | |
} | |
} | |
// 4-1 | |
package playGround; | |
import java.util.*; | |
public class testJava{ | |
public static void main(String[] args) { | |
Scanner temp = new Scanner(System.in); | |
System.out.printf("Enter Interger"); | |
int x = temp.nextInt(); | |
if(x >= 50) { | |
System.out.printf("Hi, its over 50 : %d", x); | |
} | |
else if(x >= 20) { | |
System.out.printf("Its between 20 to 50 right? : %d", x); | |
} | |
else { | |
System.out.printf("No, It is under 20 %d", x); | |
} | |
} | |
} | |
// 4-2 | |
package playGround; | |
import java.util.*; | |
public class testJava{ | |
public static void main(String[] args) { | |
int cnt = 0; | |
while(true) { | |
System.out.println("wow"); | |
cnt += 1; | |
if (cnt > 100) { | |
break; | |
} | |
else { | |
continue; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment