Java basic learning content 3 (operator / ternary operator)

What about this article?

When I relearned Java from the basics, I felt that there were many points that I had not understood so far, so I have summarized the learning contents so that I can look back on them later.

operator

Unary operators, arithmetic operators, etc. Used for calculations and comparisons.

Operators to be careful

&When&& (|When||)

Both indicate AND (OR), but & and | evaluate the right side even if the left side is false.

instanceof It is used in the following form. (I wrote it just in case I didn't know it was an operator)

instanceof


str instanceof String;

== and equals ()

Basic data types can be compared with ==, but equals () is used when comparing reference type values. (When comparing with ==, it will be compared whether the reference destination is the same.)

Ternary operator

It is used as follows. If the conditional expression before? Is true, the expression on the left is executed, and if it is false, the expression on the right is executed.

Ternary operator


   String str = "a" == null ? "is null" : "is not null";

Recommended Posts

Java basic learning content 3 (operator / ternary operator)
Java basic learning content 7 (exception)
Java basic learning content 5 (modifier)
Java Basic Learning Content 8 (Java API)
Java basic learning content 4 (repetition)
Java basic learning content 9 (lambda expression)
Java basic learning content 2 (array / ArrayList)
Java basic learning content 1 (literals, variables, constants)
Java learning memo (basic)
Java Basic Learning Content 6 (Inheritance / Abstract Class / Interface)
Java learning memo (logical operator)
Java learning (0)
Java learning day 5
Java basic grammar
Java basic grammar
Reference ternary operator
Java basic knowledge 1
[Java] Basic structure
[Java] [Basic] Glossary
Java basic grammar
Java basic grammar
Java exercises [Basic]
java learning day 2
java learning day 1
How much ternary operator is allowed in Java
Ruby learning points (basic)
java learning (conditional expression)
java basic knowledge memo
Java learning memo (method)
Java Learning (1)-Hello World
[Java] Data type ①-Basic type
About the ternary operator
Java null coalescing operator
Java basic date manipulation
JAVA learning history interface
Java basic naming conventions
Java learning memo (interface)
Java learning memo (inheritance)
[Java] Basic method notes
Java basic data types
Basic Java OOps concepts
Study Java # 2 (\ mark and operator)
Learning Java framework # 1 (Mac version)
Java basic syntax + α trap
JAVA learning history interface inheritance
[Java] Basic statement for beginners
Books used for learning Java
4th day of java learning
Ruby on Rails basic learning ①
[Java] Summary of operators (operator)
[Java] Thymeleaf Basic (Spring Boot)
Implement Basic authentication in Java
[Java] Content acquisition with HttpCliient
Java learning memo (abstract class)
Is the ternary operator evil?
[Beginner] Java basic "array" description
Java Learning 1 (learning various data types)
[Java] Basic terms in programming
[Java] Scanner, ternary operator, array operation (AOJ ① large and small alignment)