반응형
1.Data Type
public class Datatype{
public static void main (String[] args) {
System.out.println(6); //number
System.out.println("six"); // String
System.out.println("6"); //String 6
System.out.println(6+6); //12
System.out.println("6"+"6"); //66
System.out.println(6*6); // 36
//System.out.println("6"*"6");
System.out.println("1111".length());//4
//System.out.println(1111.lenght());
//데이터 타입별로 연산방법이 있다.
//어떤데이터타입이있나 , 데이터타입별로 어떤연산자를 사용할수 있는가.
}
}
2. Number
public class Number {
public static void main(String[] args) {
System.out.println(6 + 2); //8
System.out.println(6 - 4); //4
System.out.println(6 * 2); //12
System.out.println(6 / 2); //3
// + - * / sms dustkswk Operator
System.out.println(Math.PI); // 3.141592653
System.out.println(Math.floor(Math.PI)); //3.0
System.out.println(Math.ceil(Math.PI)); //4.0
}
}
3. String
public class StringApp {
public static void main(String[] args) {
System.out.println("Hello world"); //String Charater가 보인것
System.out.println('H'); // 하나의 문자(Character)
System.out.println("H"); // 문자열
System.out.println("Hello "
+ "world");
// new line
System.out.println("Hello \nworld");
// escape 한다 해방시키는것
System.out.println("Hello \"world\""); // "는 문자가 시작하고 끝내는것 \해줘야함.
}
}
4. StringOperation
public class StringOperation {
public static void main(String[] args) {
System.out.println("Hello World".length());
//replace 를 텅해 앞에 값을 뒤에값으로 바꾸게할수있다.
System.out.println("Hello, [[[name]]] ... bye".replace("[[[name]]]", "aaaa"));
//문자열에관련된 여러기능을 이용해서 문제를 해결할수있다..
}
}
'Java' 카테고리의 다른 글
java) 주석과 세미클론 (0) | 2022.02.27 |
---|---|
java)5일차 변수 (0) | 2022.02.27 |
java)4일차 -참조 (0) | 2022.02.26 |
Java)3일차 (0) | 2022.02.25 |
java) 1일차 (0) | 2022.02.23 |