Default values for eight basic data types in Java _java

Source: Internet
Author: User

Test the default values for 8 basic data types with a piece of code

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 (the default value for integer is: "+a.a);
" SYSTEM.OUT.PRINTLN ("The default value for Double-precision floating-point type is:" +a.b);
SYSTEM.OUT.PRINTLN ("The default value of Boolean is:" +A.C);
SYSTEM.OUT.PRINTLN ("The default value for character type is:" +A.D);
SYSTEM.OUT.PRINTLN ("The default value for byte is:" +A.E);
SYSTEM.OUT.PRINTLN (the default value for Single-precision floating-point type is: "+A.F);
" SYSTEM.OUT.PRINTLN ("The default value for the short integer is:" +A.J);
SYSTEM.OUT.PRINTLN ("The default value for long integer is:" +a.h);
}

The results of the operation are as follows:

The default value for integral type is: 0

The default values for Double-precision floating-point types are: 0.0

The default value for a Boolean is: false

The default values for character types are:

The following conclusions are drawn:

Base type default value

Byte
Short
Int
Long
0L
Float
0.0f
Double
0.0d
Char
' \u0000 '
Boolean
False

The above is a small set of Java to introduce the eight basic data types of the default values, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.