๋ฐ์ํ
- ๋ฌธ์์ด์ ์ซ์๋ก ๋ณํ
Integer.parseInt() ๋๋ Doouble.parseDouble()
- ์ซ์๋ฅผ ๋ฌธ์์ด๋ก ๋ณํ
์ซ์ + " " -> "์ซ์"
- ๋ฌธ์์ด์ ๋ฌธ์๋ก ๋ณํ
charAt()
์ซ์๋ก ์ธ์ํ๊ฒ ํ๋ ค๋ฉด charAt() - '0'
public class T1 {
public static void main(String[] args) {
String num1 = "50";
//๋ฌธ์์ด์ ์ซ์๋ก ๋ณํ
System.out.println(num1);
System.out.println(num1+1);
System.out.println(Integer.parseInt(num1)+1);
//์ซ์๋ฅผ ๋ฌธ์์ด๋ก ๋ณํ
System.out.println(2);
System.out.println(2+1);
System.out.println("2"+1);
//๋ฌธ์์ด์ ๋ฌธ์๋ก ๋ณํ
System.out.println(num1.charAt(0)-'0');
System.out.println(num1.charAt(1)-'0');
}
}
๋ฐ์ํ
'๐Language > โ Java' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Java] if๋ฌธ (0) | 2021.09.28 |
---|---|
[Java] Java ๊ฐ๋ฐํ๊ฒฝ ๊ตฌ์ถ - JDK, Eclipse ๋ค์ด๋ก๋ (0) | 2021.09.05 |
[Java] Scanner (0) | 2021.08.24 |
[Java] ์ฐ์ฐ์ (0) | 2021.08.24 |
[Java] ๋ณ์ (0) | 2021.08.24 |