분류 전체보기389 CompletableFuture 생성 CompletableFuture 생성 — Callable vs Supplier핵심 차이: 예외 처리 java// Callable — checked exception 던질 수 있음Callable callable = () -> { throw new Exception("checked exception 가능");};// Supplier — checked exception 못 던짐Supplier supplier = () -> { // throw new Exception("이거 컴파일 에러남"); throw new RuntimeException("unchecked만 가능");};기존 방식 (ExecutorService + Callable) javaExecutorService executor = .. 2026. 4. 8. [코테에서 자주쓰는 기본 메서드 정리5] replace replace: 이문자를 저문자로 치환1. 기본String s = "banana";String result = s.replace('a', 'o');System.out.println(result); // bonono2. 공백 제거String s="hello world";String result= s.replace(" ","_");System.out.println(result);3. 특정 문자 제거String s="a-b-c-d";String result=s.replace('-','');System.out.println(result);왠수같은 포인트원본 문자열은 안바뀐다.String s = "banana";s.replace('a', 'o');System.out.println(s); //banana문자 vs .. 2026. 4. 7. [코테에서 자주쓰는 기본 메서드 정리4] contains contains: 문자열 안에 찾고 싶은 문자열이 있냐true/false사용법1.포함 여부만 필요할때if(str.contains("error"){System.out.println("에러 있음");}2. 조건 필터링if(email.contains("@gmail.com")){ System.out.println("구글 계정");}왠수같은 포인트 1.contains는 문자 하나도 가능하다.str.contains("a")2. 대소문자 구분한다."HELLO".contains("h");//false 문자열 정리contains : 포함 되어있냐String s = "banana";s.contains("ana") // trues.contains("app") // falsestartsWith : 이걸로 시작하냐Stri.. 2026. 4. 7. [코테에서 자주쓰는 기본 메서드 정리3] substring substring: 일부 구간 잘라서 문자열String str="hello"String sub=str.substring(1,4);//ell 시작 인덱스 포함 끝 인덱스 미포함//앞뒤 자르기 특정 구간 추출에 사용한다.사용 패턴1. 앞부분 재거String str = "01012345678";String phone = str.substring(3);//123456782. 특정 기준 이후에만 가져오기String email = "test@gmail.com";String domain = email.substring(email.indexOf('@') + 1);//gmail.com3. 마지막 문자 제거String str = "hello!";String result = str.substring(str.length()-.. 2026. 4. 6. [코테에서 자주쓰는 기본 메서드 정리2] indexOf() indexOf : 문자 어딨냐 없으면 -1사용 패턴1. 문자 존재 여부 확인String str="apple";if(str.indexOf('p')!=-1){ System.out.println("p 있음");}//-1 아니면 존재사용 패턴2. 특정 문자 위치 찾기String str="avocado"int index=str.indexOf('o');System.out.println(index);//2//근데 첫번째것만 찾음왠수 같은 내 착각1. str.indexOf('o'); // 모든 o를 찾지 않음 첫번쨰꺼만 찾음2. if(str.indexOf('a')) //이거 boolean 아님 에러 이거 리턴값 int임3. if(str.indexOf('a') == 0) 이거 존재 여부 체크 아님중요 패턴문자 여러개.. 2026. 4. 6. [코테에서 자주쓰는 기본 메서드 정리1] charAt() charAt: 특정 위치 문자 하나 뽑을 때 쓴다. 한글자반복문이랑 같이 쓰는게 진짜 핵심이다.//1.문자열을 배열처럼 쪼개서 순회할때String str="hello";for(int i=0; i//2. 특정 문자 찾기String str="apple";for(int i=0;i해석:"Returns the char value at the specified index."→ 지정한 인덱스 위치에 있는 문자를 반환한다."An index ranges from 0 to length() - 1."→ 인덱스는 0부터 문자열 길이 - 1까지다."The first char value of the sequence is at index 0, the next at index 1, and so on, as for array inde.. 2026. 4. 6. 이전 1 2 3 4 ··· 65 다음