목록java (76)
gwooden_코린이
charAt(int index) equals(Object obj) trim() package 자바API; public class Sample04 { public static void main(String[] args) { // 123456789.....쭉~ String str = "Hello My Name is Hong Gil Dong"; String str2 = " Hello My Name is Hong Gil Dong "; System.out.println("===기본 입력 된 값==="); System.out.println("Hello My Name is Hong Gil Dong"); System.out.println("===기본 입력 된 값==="); System.out.println("\n==6..

package 자바API; public class Sample03 { public static void main(String[] args) { System.out.println(System.getProperty("java.version")); System.out.println(System.getProperty("java.home")); System.out.println(System.getProperty("os.name")); System.out.println(System.getProperty("file.separtor")); System.out.println(System.getProperty("user.name")); System.out.println(System.getProperty("user.home..

package 자바API; public class Sample02 { public static void main(String[] args) { // Clone String[] arr = {"홍", "이", "김", "안"}; String[] arr2 = arr.clone(); for(String a : arr) { //arr 배열방에 있는 값들이 순서대로 a에 대입되면서 전부 출력된다. System.out.println(a); } arr2[1] = "박"; for(String a : arr2) { System.out.println(a); } } }

기본 자바 API equals, hashCode package 자바API; public class Sample01 { public static void main(String[] args) { // equals 메서드 //String str1 = "abc";랑 같은 코드 String str1 = new String("abc"); //새롭게 객체를 생성 String str2 = new String("abc"); System.out.println("str1 : " +str1.hashCode()); System.out.println("str2 : " +str1.hashCode()); System.out.println("str1 : " + System.identityHashCode(str1)); System.ou..
상품발송() { try { 포장(); 영수증(); 발송(); }catch(예외) { 취소(); } } 포장(); throw Exception { } 영수증(); { } 발송(); { }

예외 강제 발생은 코드문이 잘 작동되고 있나 테스트 할 때 쓰임 package 예외처리; public class Sample { public static void main(String[] args) { //throw thorws System.out.println("프로그램 시작"); try { throw new Exception("예외 발생"); } catch(Exception e) { System.out.println(e.getMessage()); } System.out.println("프로그램 종료"); } } 예외 떠넘기기 throws package 예외처리; public class Main { public static void main(String[] args) { Div d = new Div()..

package 예외처리; public class Exception2 { public static void main(String[] args) { System.out.println("DB연결 시작"); try { System.out.println("DB작업"); System.out.println(3/0); } catch (Exception e) { System.out.println(e); System.out.println(e.getMessage()); System.out.println(e.toString()); e.printStackTrace(); } finally { System.out.println("DB연결 종료"); } } }

package 예외처리; public class ExceptionEx2 { public static void main(String[] args) { try { int[] arr = {1, 2, 3}; System.out.println(arr[3]); //문맥상 이상이 없지만 배열방은 위에서 3가지로 되어있어 arr[2]가 맞는것 System.out.println(3/0); Integer.parseInt("a"); //괄호안에 넣어준것들을 정수로 바꿔주는 메서드 } catch (ArithmeticException e) { System.out.println("0으로 나눌수 없다"); } catch (ArrayIndexOutOfBoundsException e) { System.out.println("인덱스 범..