-
[30일코딩] 사칙연산과 논리연산개발입문/JAVA 2017. 5. 3. 21:02
대수의 기본은 사칙연산 4개과 나머지(%) 이다.
나머지는 나중에 자알~ 활용하는 값이 있으므로 알아만 놓자.
그 외 논리연산자: 같음(등호), 같지않음(부등호), 큼/작음 등이있다.
컴퓨터는 1 or 0 이나 같다/같지않다와 같이 이분법적으로 값을 인식한다.
산술연산자 Arithmetic Operators
Arithmetic Operators
The binary operators used for arithmetic are as follows:+
: Additive-
: Subtraction*
: Multiplication/
: Division%
: Remainder (modulo)
논리연산자 Logical OperatorsAdditional Operators
+
: A binary operator used for String concatenation++
: This unary operator is used to preincrement (increment by 1 before use) when prepended to a variable name or postincrement (increment by 1 after use) when appended to a variable.--
: This unary operator is used to predecrement (decrement by 1 before use) when prepended to a variable name or postdecrement (decrement by 1 after use) when appended to a variable.!
: This unary operator means not (negation). It's used before a variable or logical expression that evaluates to true or false.==
: This binary operator is used to check the equality of 2 primitives.!=
: This binary operator is used to check the inequality of 2 primitives.<
,>
,<=
,>=
: These are the respective binary operators for less than, greater than, less than or equal to, and greater than or equal to, and are used to compare two operands.&&
,||
: These are the respective binary operators used to perform logical AND and logical OR operations on two boolean (i.e.: true or false) statements.? :
This ternary operator is used for simple conditional statements (i.e.: if ? then : else).
DataType Casting
같은 숫자 int, double 끼리도 연산을 하다보면
가장 호환범위가 넓은 데이터타입 으로 데이터타입이 변동된다.
따라서 필요할 경우에는 연산결과의 데이터타입을 Casting (변환) 해야한다.
출처 | https://www.hackerrank.com/challenges/30-operators/tutorial
'개발입문 > JAVA' 카테고리의 다른 글
[30일코딩] 클래스와 인스턴스 (0) 2017.05.05 [30일코딩] 조건문 Conditional Statement (0) 2017.05.05 [30일코딩] 생성자 Constructor (0) 2017.05.03 [30일코딩] 데이터타입 DataType (0) 2017.05.03 [30일코딩] 선언, 할당, 초기화 (0) 2017.05.03