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
/* 양다인 */ | |
import java.lang.annotation.*; | |
import java.lang.reflect.*; | |
// 어노테이션 정의, 속성이 없는 마커 어노테이션 | |
@Retention(RetentionPolicy.RUNTIME) | |
@Target(ElementType.METHOD) | |
@interface LogParams { | |
} |
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
/* 양다인 | |
Prototype Pattern 구현 | |
기존 객체를 복제하여 새로운 객체를 생성하는 패턴으로, Cloneable 인터페이스를 사용한다. | |
Cloneable 인터페이스는 clone() 메소드를 호출하여 얕은 복사를 수행하고 객체를 복제한다. | |
복제한 객체들의 내용은 동일하지만 래퍼런스는 다르고, 복제본을 수정해도 원본은 변하지 않는다. | |
Prototype Pattern은 객체 생성 비용이 감소하고 동적 객체를 생성할 수 있으며 객체 생성 시간이 단축된다는 특징이 있다. | |
*/ | |
import java.util.ArrayList; | |
import java.util.List; |
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
/* 양다인 */ | |
import java.io.IOException; | |
import java.nio.file.Files; | |
import java.nio.file.Path; | |
import java.util.Scanner; | |
import java.util.function.Function; | |
import java.util.stream.Stream; | |
public class JavaStudy23 { |
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
/* 양다인 | |
스마트폰 모델을 입력하면 | |
모델 설명과 모델이 속한 브랜드의 설명을 출력하는 코드 | |
각 모델과 브랜드를 어노테이션으로 관리함 | |
*/ | |
import java.lang.annotation.*; | |
import java.lang.reflect.Method; | |
import java.util.Scanner; |
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
/* 양다인 */ | |
import java.util.Scanner; | |
public class HomeWork7 { | |
public static void main(String[] args) { | |
Scanner sc = new Scanner(System.in); | |
int[] section = {12000000, 34000000, 42000000, 62000000, 150000000, 200000000, 500000000, Integer.MAX_VALUE}; // 구간별 차이 (최대 약 21억원까지 소화 가능) | |
double[] rate = {0.06, 0.15, 0.24, 0.35, 0.38, 0.40, 0.42, 0.45}; // 세율 |
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
/* 양다인 */ | |
import java.util.*; | |
public class HomeWork6 { | |
public static void lotteryDraw(TreeSet<Integer> lottoNumbers) { // 중복 없이 6개의 번호를 뽑는 메서드 | |
Random random = new Random(); | |
while (lottoNumbers.size() < 6) { | |
int num = (random.nextInt(45) + 1); |
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
/* 양다인 */ | |
import java.util.concurrent.CompletableFuture; | |
import java.util.concurrent.TimeUnit; | |
public class JavaStudy21 { | |
public static void main(String[] args) { | |
CompletableFuture.supplyAsync(() -> { | |
System.out.println("💳 결제 요청 중... (50000원)"); | |
//타임아웃 유도 블록, 주석처리 하면 성공 케이스 반환 |
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
/* 양다인 */ | |
import java.util.stream.LongStream; | |
public class JavaStudy20 { | |
public static void main(String[] args) { | |
long start = System.currentTimeMillis(); | |
long sumSequential = LongStream.rangeClosed(1, 500_000_000L) | |
.sum(); |
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
/* 양다인 */ | |
import java.time.LocalDateTime; | |
import java.util.concurrent.Executors; | |
import java.util.concurrent.ScheduledExecutorService; | |
import java.util.concurrent.TimeUnit; | |
public class JavaStudy19 { | |
public static void main(String[] args) { | |
//ScheduledExecutorService 사용, 1개의 스레드만 생성 |
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
/* 양다인 */ | |
class UserAuth { //로그인할 유저 정보 ThreadLocal | |
private static ThreadLocal<UserAuth> userThreadLocal = new ThreadLocal<>(); | |
private String name, password; | |
UserAuth (String name, String password) { | |
this.name = name; | |
this.password = password; | |
} |
NewerOlder