Java review ① (development steps, basic grammar, variables, data types)

Part 1 "Steps of java program development"

  1. Creating source code
  2. Compile
  3. Run The above 3 steps

Part 2 "Let's take a closer look"

  1. What is source code creation? A statement to a computer that can be read by humans. It's just called sauce. A source file is a description of the source file. Therefore, the java file written as 〇〇.java is applicable.
  2. Compile It is done by software called a compiler. Convert the source file to a class file (〇〇.class). The contents of the class file are bytecodes Bytecode is computer readable (binary).
  3. Run Use an interpreter to convert bytecode to machine code and execute it. The JVM is included in the interpreter, and it is the JVM that actually reads and converts the bytecode. The converted machine code is sent to the CPU. [Summary of Part 2] ・ Human readable = source code -File containing source code = source file -Computer (with JVM) can read = bytecode -File containing bytecode = class file -What is required to convert the source code to bytecode = compiler -Compile the above work -It is the interpreter that executes bytecode as machine code. -To use Java, you need to install an interpreter and compiler on the net.

Part 3 "Basics of Java"

  1. Block {} Blocks are surrounded by curly braces. If public class Main {}, class block public static void main (String [] args) If {} is a method block Write the instruction in the method block.
  2. Class name rules Class names start with an uppercase alphabet.
  3. java file rules クラス名.java
  4. How to write the source (1) Be sure to close the block and write. The following description is ✖️ ————————————————— public static void Hello(){ System.out.println(“hello”); ————————————————— ② Incident Utilize tabs and spaces. Readable code. ③ Comment / * * / Or //
  5. Code execution order It is executed in order from the top.
  6. Add a semicolon. ";" ← Source of error

Part 4 "Variables"

  1. What are variables? A box that holds various values that are not constant. If it is a number, it can be from minus to 0, tens of thousands or more values can be entered, and it can be called a character string or a boolean value. Various values are entered.
  2. Declaration of variables int number; Type + variable name + semicolon
  3. Variable name rules ① You cannot use what is called a reserved word. For example, since int is used as a type, int cannot be used as a variable name. ② If you have already used it, you cannot use it. It cannot be used exactly within the same scope. However, it is better to make it so that it will not be covered. ③ Characters are case sensitive. ④ Basically lowercase. When two words are connected like myName Capitalize only the first letter of Name.
  4. Variable declaration and assignment int number = 30; Type + variable name + equal + value to be assigned + semicolon
  5. Overwrite variables Please note that it is executed in order from the top. The values below are displayed on the screen.
  6. Constant Variables that you do not want to be rewritten are made constants and set to constant values. final double number = 3.14;

Part 5 "Data type" int integer long big integer double Ordinary decimal (L is added at the end like 10000000000L) float Ambiguous decimal (F at the end like 30.2F) boolean Boolean (only true or false can be entered) char single character (use single quotes like'turtle') String String (uppercase)

Tips "Purpose of java" Java is built on the idea that it works everywhere. To work anywhere means to create bytecode that can be understood by any CPU. The JVM in the computer reads the bytecode The JVM inside the computer is executing the bytecode, not just the computer It is called a JVM (java virtual machine) because it looks like this. (JVM passes the machine code that converted the bytecode to the CPU, so it is actually just converting) "

Recommended Posts

Java review ① (development steps, basic grammar, variables, data types)
Java basic data types
Basic data types and reference types (Java)
Java basic data types and reference types
Java basic grammar
Java basic grammar
Java basic grammar
[Java] Data type ①-Basic type
[Java] Main data types
[Java] Variables and types
About Java basic data types and reference type memory
Java Learning 1 (learning various data types)
Review of Ruby basic grammar
[Java] Basic types and instruction notes
Java Primer Series (Variables and Types)
[Introduction to Java] Variables and types (variable declaration, initialization, data type)
Basics of Java development ~ How to write programs (variables and types) ~
[Basic knowledge of Java] Scope of variables
[Java] Exception types and basic processing
Java starting from beginner, variables and types
Basic knowledge of Java development Note writing
[Java] I personally summarized the basic grammar.
Java basic learning content 1 (literals, variables, constants)
Basic Java grammar you should know first
Java engineers now compare to learn the basic grammar of Ruby Part 1 (Basic, Variables)
Java review
About Java data types (especially primitive types) and literals
Java review ③ (Basic usage of arrays / reference type)