생활코딩 JAVA1로 공부한 내용을 정리하였습니다
python의 print();
Javascript의 console.log();
-> Java에는 System.out.println();
"String" => String;
'String' => Error
'S' => Character;
System.out.println("hello \nWorld") => hello
world //줄바꿈
System.out.println("큰따옴표 안에서 문자로 큰따옴표를 쓰는 \"상황\" 에는 이렇게");
-> 큰따옴표 안에서 문자로 큰따옴표를 쓰는 "상황" 에는 이렇게
int => 정수;
double => 실수;
String => 문자열;
System.out.println(6); //number
System.out.println("6"); //String
System.out.println(6+6); //number 12
System.out.println("6" + "6"); //String "66"
System.out.println(6*6); //number 36
System.out.println("6"*"6"); //number 36
String name = "Tom";
int age = 28;
System.out.println("My name is "+name+",I'm "+age+" years old ");
=> My name is Tom,I'm 28 years old
String.length() => 공백을 포함한 문자열의 길이
String.replace(a,b) => a를 b로 대체한다
String a = "Hello World";
System.out.println(a.length()); //공백을 포함함
=> 11
System.out.println("Hello [[[name]]] nice to meet you".replace("[[[name]]]", "Ben"));
=> Hello Ben nice to meet you
double a = 1.2; // 1.2
double b = 1; //1.0 정수이지만 double을 써도 오류 없음 -> 손실이 없기 떄문
int c = 1; // 1
int d = 2.1; //Error
int e = (int) 2.1 // 2.0 값은 손실은 낫지만 오류없이 출력됨
double f = 33; // dobule f = (dobule)33;이랑 같음