I started learning Java from today, so I hope it will be helpful for those who read the output.
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."
Type variable name;
A type is the type of data that can be stored in a variable.
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 |
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
}
}
700000
7.9
Treasure
I love you
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