About Java variable declaration statements

Java variable declaration

I started learning Java from today, so I hope it will be helpful for those who read the output.

First of all, what are variables and variable declaration statements?

Variables are like boxes that you prepare inside your computer to store data. In other words, a variable declaration is a statement that tells the computer to "prepare a new variable."

Variable declaration statement

Type variable name;

A type is the type of data that can be stored in a variable.

Commonly used mold types (there are others)

Classification Model name Data to store
integer int 普通のinteger
a few double Ordinary decimal
Boolean value boolean true or false
letter char 1つのletter
String String Character sequence

Example of use

This time, I would like to introduce my car as an example. twitter

Classification Model name Data to store If you compare it with your car (look)
integer int 普通のinteger amount:Amount of money
a few double 普通のa few weight:weight
Boolean value boolean true or false sell:Sell or not sell
letter char 1つのletter value:Treasure
String String Character sequence comment:I love you

I actually wrote it. The boolean value will be learned from now on, so it is omitted.

look.java



public class Main {
  public static void main(String[] args) {
    int amount = 700000; //Substitute a value in the amount box
    System.out.println(amount); //Description to call
    double weight = 7.9; //Substitute the value in the weight box
    System.out.println(weight); //Description to call
    char value = 'Treasure'; //Substitute a value in the value box
    System.out.println(value); //Description to call
    String comment = "I love you"; //Assign a value to the comment box
    System.out.println(comment); //Description to call
  }
}

Execution result

700000
7.9
Treasure
I love you

Impressions

Actually, it was my first time to post an article. It takes 2 hours to create an article. (It took a lot) As a goal, I will post articles once a week. Thank you to everyone who read to the end!

Recommended Posts

About Java variable declaration statements
java variable declaration
Java variable declaration, initialization, and types
How to write Java variable declaration
About Java interface
[Java] About Java 12 features
java array variable
[Java] About arrays
Something about java
Where about java
Java variable scope (scope)
About Java features
About Java threads
[Java] About interface
About Java class
Java variable scope
About Java arrays
About java inheritance
About interface, java interface
About List [Java]
About java var
About Java literals
About Java commands
About var used in Java (Local Variable Type)
[Java] Use of final in local variable declaration
About Java log output
About Java functional interface
Java, about 2D arrays
About class division (Java)
About [Java] [StreamAPI] allMatch ()
About Java StringBuilder class
[Java] About Singleton Class
About Java method binding
[Java] About anonymous classes
About method splitting (Java)
[Java Silver] About initialization
Regarding Java variable usage
About Java Array List
About Java Polymorphism super ()
About inheritance (Java Silver)
About Java String class
About Java access modifiers
About Java lambda expressions
About Java entry points
About Java 10 Docker support
Personal summary about Java
[Java] About enum type
All about Java programming
About java abstract class
Java variable declaration, initialization, data type (cast and promotion)
[Java Silver] (Exception handling) About try-catch-finally and try-with-resource statements
A note about Java GC
[Java] Variable name naming memo
What I researched about Java 8
About an instance of java
What I researched about Java 6
[Gradle] About Java plug-in tasks
What I researched about Java 9
[Java] About try-catch exception handling
About Java class loader types
Java if and switch statements