<1.4. Arithmetic Operators>
- Arithmetic operations of Java is also similar to that of C and C++.
- 나눗셈에서 양쪽 모두 int면 결과는 int, 한쪽이라도 실수면 결과는 실수. (숫자말고 변수로 적혀있으면 헷갈린다)
- Static메소드는 class자체에 속한 것이고, instance메소드는 object에 속한다.
ex) Math.sqrt(x)에서 Math는 class, sqrt는 static method이다.
- automatic conversion은 byte -> shrot -> int -> long -> float -> double.
when assign right data type to left, you must use type cast operator.
- type casting해도 수가 그 범위를 벗어나면 이상한 값이 할당된다.
- &&와 ||에서 앞 조건 확인 후 뒷 조건 확인 필요없으면 검사자체를 안 한다. (문법상 오류여도 상관X)
cf) System.out.println() 내부에 +사용하면 나란히 출력해준다.
<EX 소스코드>
github.com/HoYoungChun/Java_Language_Lecture/tree/master/EX03
HoYoungChun/Java_Language_Lecture
Contribute to HoYoungChun/Java_Language_Lecture development by creating an account on GitHub.
github.com
'JAVA > JAVA_Lecture' 카테고리의 다른 글
Lecture 05: Java Programming Basics (4) (0) | 2020.10.08 |
---|---|
Lecture 04: Java Programming Basics (3) (0) | 2020.09.14 |
Lecture 02: Java Programming Basics (1) (0) | 2020.09.09 |
Lecture 01: Course Intro / Introduction to Java (0) | 2020.09.09 |
Java Language Syllabus (0) | 2020.09.09 |