Skip to content

Instantly share code, notes, and snippets.

View AndersonChoi's full-sized avatar
🇰🇷
안녕하세요

AndersonChoi AndersonChoi

🇰🇷
안녕하세요
View GitHub Profile
class ChildBook implements Book{
private final int code=1;
private final int point=1000;
@Override
public int priceCode(){
return this.code;
}
@Override
public int getPointPercent(){
public interface Book{
int priceCode();
int getPointPercent();
}
//catch 블록을 비우면 예외는 무시된다.-이상한코드...
try{
....
} catch (someException e){
}
public Object pop(){
if(size==0)
throw new EmptyStackException();
Object result = element[--size];
...
//기타코드
return result;
}
public IndexOutOfBoundsException(int lowerBound, int upperBound, int index){
//파라미터로 부터 오류를 알 수 있는 상세한 메시지 작성
super("Lower bound: "+lowerBound +
", Upper bound: "+upperBound +
", Index: "+index);
//프로그램에서 이용할 수 있도록 오류 정보보관
this.lowerBound = lowerBound;
this.upperBound = upperBound;
this.index = index;
if(obj.fileIOPermitted(args)){
obj.fileIO(args);
}else{
//예외사항 처리...
...
}
try{
obj.fileIO(args);
}catch(FileInputOutputException e){
//예외사항 처리...
...
}
import java.util.Calendar;
public class TestExceptionPerformance {
public static void main(String[] args) {
int count[] = new int[100000];
long startTime = System.currentTimeMillis();
for (int i = 0; i < count.length; i++) { count[i]++; }
import java.util.Calendar;
public class TestExceptionPerformance {
public static void main(String[] args) {
int count[] = new int[100000];
long startTime = System.currentTimeMillis();
try {
try{
int i = 0;
while(true)
personArray[i++].addCount();
}catch(ArrayIndexOutOfBoundsException e){
}