Muscle Java Basics Day 1

Program diary of fledgling brain muscle Summarize what you have learned

Java features

--Grammar type that follows C / C ++ --Object-oriented language --Static type language --Variables, arguments and return values must be typed! !!

Java Virtual Machine(JVM/JavaVM) --A virtual machine that can interpret and execute Java binary format as it is --Get common execution results by using a dedicated Java VM for each OS

What is a class? !!

--Defining a program that can collectively define states / situations and behaviors / behaviors

Car class condition Behavior / behavior
car_character3_wagon.png Vehicle type
color
Number of doors
Run
Bend
Go down

__ How to define a class __

class class name(){
Define state / situation
Define behavior / behavior
}

What is a method? !!

--Definition of __ "behavior" and "behavior" __ in the class

__ How to define a method __

class class name(){
Define state / behavior

Return type method name(argument){
Behavior / behavior processing
 }
}

--Use (call) a method --When the caller calls the method, the processing in the method is executed and the processing result is returned to the caller. --Arguments --When calling the method, pass the information required for processing as __ "argument" __

image.png

definition of main method

--What is the main method? --Method executed when the program is started ――The way of definition is decided

public static void main(String[] args){

}

Data type

Data type Model name Contents Range of values
Integer type int
long
byte
32-bit integer
64-bit integer
8-bit integer
abridgement
abridgement
abridgement
Real type float
double
32-bit single precision real number
64-bit single precision real number
abridgement
abridgement
Character type char 1 character abridgement
Logical type boolean Two-valued logical value true or false

How to define variables

--Java variables --Java variables always require "type definition" -Unable to assign a value other than the defined type to a variable ――This is called "static typing"

Type name Variable name = Initial value;
int a = 10;

Fields and local variables

--Field --Variables declared inside the class definition --Local variables --Variables declared inside the method definition

public class sample{
  //field
  String name = "Taro";

  //Method
 public void walk(){
  //Local variables
  int age = 20;  
 }
}

Recommended Posts

Muscle Java Basics Day 1
Java Day 2018
Java basics
Java basics
Muscle Java Object Oriented Day 1
Java basics
Muscle Java Object Oriented Day 2 ~ Inheritance ~
Java learning day 5
java programming basics
Java Day Tokyo 2017
Oracle Java Day 2017
Java JAR basics
Object-oriented (Java) basics
Oracle Java Day 2017
Java concurrency basics
java learning day 2
java learning day 1
Java Silver Study Day 1
Java Kuche Day memo
Java programming basics practice-array
Java Network Basics (Communication)
Basics of character operation (java)
4th day of java learning
Java programming basics practice-for statement
Java programming basics practice-switch statement
Getting Started with Java Basics
Java Development Basics ~ Exercise (Array) ~
[Java11] Stream Usage Summary -Basics-
[Java basics] What is Class?
Java is the 5th day
[Study session memo] Java Day Tokyo 2017
Java
Java Performance Chapter 5 Garbage Collection Basics
Memorandum of new graduate SES [Java basics]
Looking back on the basics of Java
Muscle Ruby on Rails Day 1 ~ Environment Construction ~
Basics of java basics ② ~ if statement and switch statement ~