JAVA variable type, definition variable, java variable Type Definition
Common Data Types in JAVA
Data Type |
Data Type description |
Description |
Char |
Character Type |
Used to store a single character, such as gender "male", "female", electric lights "on", and "off" |
Int |
Integer |
Used to store integers, such as 24 hours a day and 31 days a month. |
Double |
Double Precision |
Used to store decimals. For example, the price of Mengniu's breakfast milk is 1.3 yuan, and the phone's standby time is 6.5 hours. |
String |
String |
It is used to store a string of characters, such as "My hobby is playing football" and "I like Java programs" |
Boolean |
Boolean Type |
Only one of the two values can be assigned: true or false) |
Define Variables
Public class Test {public static void main (String [] args) {char a = 'P'; // declare and assign a value to the int number = 123 variable of the character type (single character; // declare and assign the integer Variable double B = 1.5; // declare and assign the double-precision variable String d = "zifuchuan "; // declare and assign values to string variables // output System. out. println (a); System. out. println (number); System. out. println (B); System. out. println (d );}}