Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- JSON형식의 response
- WAS
- 한글깨짐
- Servlet
- 피그마
- POST방식
- CONTINUE
- 김영한
- https://www.inflearn.com/course/lecture?courseslug=%ea%b9%80%ec%98%81%ed%95%9c%ec%9d%98-%ec%8b%a4%ec%a0%84-%ec%9e%90%eb%b0%94-%ea%b8%b0%eb%b3%b8%ed%8e%b8&unitid=194711
- 톰캣
- Break
- 매핑 #
- Forwarding
- Spring MVC
- 화면정의서
- webserver #WAS #ServerApp
- https://www.inflearn.com/course/lecture?courseslug=%ea%b9%80%ec%98%81%ed%95%9c%ec%9d%98-%ec%8b%a4%ec%a0%84-%ec%9e%90%eb%b0%94-%ea%b8%b0%eb%b3%b8%ed%8e%b8&unitid=194690
- while문
- sendRedirect
- 요구사항정의서
- https://www.inflearn.com/course/lecture?courseslug=%ea%b9%80%ec%98%81%ed%95%9c%ec%9d%98-%ec%8b%a4%ec%a0%84-%ec%9e%90%eb%b0%94-%ea%b8%b0%eb%b3%b8%ed%8e%b8&unitid=194709&category=questiondetail&tab=community&q=1314387
- 다형성 #부모타입 #자식타입
- GET방식
- Request
- xml
- Dispatcher
Archives
- Today
- Total
Step it up now
if문 본문
if 와 else if
if 문이 각각 따로 존재하는경우 - 모두 실행됨 (ex.중복할인)
public class If5 {
public static void main(String[] args) {
int price = 10000;
int age = 10;
int discount = 0;
if(price >= 10000){
discount = discount + 1000;
System.out.println("10000원 이상 구매, 1000원 할인"); //10000원 이상 구매, 1000원 할인
}
if(age <=10 ){
discount = discount +1000;
System.out.println("어린이 1000원 할인");//어린이 1000원 할인
}
System.out.println("총 할인 금액 : "+ discount + "원");//총 할인 금액 : 2000원
}
}
if 안에 else if 넣은 경우 - true인 조건 하나만 실행됨
public static void main(String[] args) {
int price = 10000;
int age = 10;
int discount = 0;
if (price >= 10000) {
discount = discount + 1000;
System.out.println("10000원 이상 구매, 1000원 할인"); //10000원 이상 구매, 1000원 할인
} else if (age <= 10) {
discount = discount + 1000;
System.out.println("어린이 1000원 할인");
} else {
System.out.println("할인 없음");
}
if 문 { } 중괄호 생략
실행할 명령이 하나만 있을 경우 가능
if (true)
System.out.println("if문에서 실행됨");
두번째 문장을 if문과 무관하기에 둘다 if문 안에 포함하려면 { } 필요
if (true)
System.out.println("if문에서 실행됨");
System.out.println("if문에서 실행 안 됨");
'개인공부 > java' 카테고리의 다른 글
형 변환 casting (0) | 2024.04.01 |
---|---|
스코프 (0) | 2024.03.31 |
메서드 호출, 값 전달 (1) | 2024.01.15 |
인터페이스 (1) | 2023.12.17 |
추상메서드/ 추상클래스 (0) | 2023.12.12 |