package study;
public class _02_study {
public static void main(String[] args) {
int result = 1;
int exponent = 6;
for (int i = 0; i < exponent; i++ ) {
result *= 3;
System.out.println(result+ "[[" + i + "]]");
}
System.out.println("---------------------");
System.out.printf("3의 %d 승은 %d", exponent, result);
System.out.println("---------------------");
System.out.println("---------------------");
result= 0;
for (int i = 0; i < 1 ; i++) {
result += 2;
System.out.println("2를" + i + "번 더하면" +result);
}
}
}
결론만 말하면 진짜 딴거 안건드리고
System.out.printf("3의 %d 승은 %d", exponent, result);
System.out.println("---------------------");
이거 후에 바로 아래에 출력되는게 불편해서
System.out.println("---------------------");
이거 한 줄 더 추가 했더니 정상 출력이 되었음;;;
처음에는 첫번 째 for문에 있는 int i로 인해 모종의 상호작용으로 그렇게 된건가 하고
package study;
public class _03_study {
public static void main(String[] args) {
int result= 0;
for (int i = 0; i < 1 ; i++) {
result += 2;
System.out.println("2를" + i + "번 더하면" +result);
}
}
}
새 클래스 열어서 여기서 문제있는 for문만 따로 출력해봤더니 여기서는 0부터로 정상 출력이 되더라고
그래서 첫번 째 for문이 무언가를 건드린거구나 하고 이것저것 건드리기 전에
출력문
3의 6 승은 729---------------------
2를1번 더하면2 (지금은 0번으로 잘나옴;;;)
으로 나오는게 불편해서
System.out.println("---------------------");
한줄 더 출력해서 문제 찾아야겠다라고 출력된거 보자마자
2를1번 더하면2 가
2를0번 더하면2 로 바뀌어있었음;;
아무튼 핑프새끼 질문 답변해주러 와줘서 고맙다...