Home > Java > javaTutorial > body text

Default values ​​for eight basic data types in Java

高洛峰
Release: 2017-01-22 10:15:37
Original
1938 people have browsed it

Use a piece of code to test the default values ​​of 8 basic data types

package dierge;
public class Ceshi {
int a;
double b;
boolean c;
char d;
float f;
byte e;
long h;
short j;
public static void main(String args[]){
Ceshi a=new Ceshi();
System.out.println("整型的默认值是:"+a.a);
System.out.println("双精度浮点型的默认值是:"+a.b);
System.out.println("布尔型的默认值是:"+a.c);
System.out.println("字符型的默认值是:"+a.d);
System.out.println("byte的默认值是:"+a.e);
System.out.println("单精度浮点型的默认值是:"+a.f);
System.out.println("短整型的默认值是:"+a.j);
System.out.println("长整型的默认值是:"+a.h);
}
}
Copy after login

The running results are as follows:

The default value of integer type is: 0

Double precision The default value of floating point type is: 0.0

The default value of Boolean type is: false

The default value of character type is:

The following conclusions are drawn:

Basic type default value

byte
short
int
long
0L
float
0.0f
double
0.0d
char
'\u0000'
boolean
false

The above are the default values ​​​​of the eight basic data types in Java introduced by the editor. I hope it will be helpful to you. Everyone is helpful. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank you all for your support of the PHP Chinese website!

For more articles related to the default values ​​of the eight basic data types in Java, please pay attention to the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template