[JAVA] Basic knowledge

[1] Flow until execution

① Source code description
・ Code written by people  
② Compile execution
-Conversion from source code to bytecode
-Software called a compiler implements  
 
② Bytecode execution
・ Bytecode → Conversion to machine language
-Run with software called an interpreter
-The interpreter is executed by a mechanism called JVM  
④ Instruct the CPU of the computer

[2] Variables

How to name variables
・ Do not use about 50 prohibited words
-Basically start with a lowercase letter, and when combining two or more words, capitalize the first letter of the second word
Data firm
-Integers are basically "int"
・ A few are basically "double"
-The boolean value is "boolen"
・ Character with only one character is "char"
-The character string is "String"
## [3] Operator / Operand
Operator Elements that make up the calculation formula [=, +, *, /,%]
Operand Other values used in the code
Literal Value set in the source code  
## [4] Escape sequence
Basic idea
Normally, "means the start or end of a character string. However, by putting \, which is one of the escape sequences, before", "" is recognized as a character string. dd>
## [5] Operator evaluation mechanism   
Concept of evaluation order of calculation formula
* * Same order as learned in mathematics *
・ Priority 1: Multiplication / Division
・ Priority 2: Addition / subtraction
・ Exception: When enclosed in (), the calculation in () has priority
・ + operator is evaluated from the left, = operator is evaluated from the right

[6] Types of operators

Basic operators
[+, ー, *, /,%]
Note the following when dividing
[/] In the case of a calculation in which there is a remainder between integers (example: 9/2), the quotient is returned (example: 4). Therefore, when finding the correct value, use a small number of either operand (example: 9.0 / 2)
[%] Calculate the remainder
Assignment operator
・ a ○ = 1 → agree with a = a ○ 1 ※ ○ is an operator
Increment Decrement
・ a ++ → Same meaning as a = a + 1 (increment)
・ a--→ Same meaning as a = a-1 (decrement)
## [7] Automatic type conversion at the time of substitution  
・ Basic idea
"In principle, only that type can be assigned to a variable declared with a certain type. However, each numeric type has a magnitude relation, and the value of a small type → the assignment to a large type is automatically converted." / dd>

Recommended Posts