⚡ 자동실행 메소드 + 재귀함수는 x
class sese{
public sese() {
LinkedList<String> ss = this.add_ex15();
this.sarr2.add(ss);
System.out.println(this.sarr2);
new sese(); // new를 넣어주면 reset되기 때문에 재귀가 의미가 없다
}
}
🔽
class exam15t_box {
public void abc() {
//머시기
abc(); //이게 맞음 (즉시실행함수 아님)
}
}
https://dev-eunse.tistory.com/73
⚡ 예외처리
package exam;
import java.util.ArrayList;
import java.util.Arrays;
/*6.
{"1000","2000","","400","","600"} 를
예외처리 적용시켜 정상적으로 출력되는 코드 작성
해당 배열을 문자배열->숫자배열로 출력하되 ""는 0으로 처리
결과 : [1000, 2000, 0, 400, 0, 600]
*/
public class exam17 {
public static void main(String[] args) {
String arr[] = {"1000","2000","","400","","600"};
ArrayList<Integer> result = new ArrayList<Integer>();
int f;
for(f=0; f<arr.length; f++) {
try {
Integer aa = Integer.parseInt(arr[f]);
result.add(aa);
}catch(java.lang.NumberFormatException e2) {
result.add(0);
}
}
System.out.println(result);
}
}
👀내가 해보니까~
예외처리 : if else와 비슷한데 좀더 포괄적인 느낌..? 오류나냐 안나냐로만 나눠서 출력!
try( 명령 ) 에서 오류난것들은 싹다 catch에서 실행!
throw 사용하는 경우 : 타 메소드로 뭔가를 던지고 받고 하는 경우에 사용 / 단, 꼭 try ~ catch로 받아야함
⚡ Date()
날짜를 저정하는 현태 데이터일 경우 최종 마지막 입력사항 밑에 처리가 되어야 한다!!!
(딱 이벤트 호출시에 시간이 입력되어야 함)
https://dev-eunse.tistory.com/73 5번 참고