๋ฐ์ํ
if ๋ฌธ ๋์ ์ฌ์ฉ ๊ฐ๋ฅํ ์ผํญ ์ฐ์ฐ์.
public class Test1{
public static void main(String[] args) {
/*=======================
* 3ํญ ์ฐ์ฐ
* ======================
*/
String s = "Ab^^abc";
String answer = "";
int idx = -1;
String[] arr = s.split("");
for(String ss : arr) {
idx = ss.contains("^") ? -1 : idx + 1;
answer += (idx % 2 == 0) ? ss.toUpperCase() : ss.toLowerCase();
}
System.out.println(answer);
/*========================
* ๊ณต๋ฐฑ ํ
์คํธ
* =======================
*/
String a = "^ ^";
System.out.println(a);
System.out.println(a.toUpperCase());
}
}
์ผํญ ์ฐ์ฐ์
if( 5 > 4 ){
int a1 = 50;
} else{
a1 = 40;
}
์ ์๋ ๋๋ค ๊ฐ์ ๊ฒฐ๊ณผ๋ฅผ ๊ฐ๋๋ค.
int a1 = (5 > 4) ? 50 : 40;
๋ฐ์ํ