Default Value of java 8 Basic Data Types

Source: Internet
Author: User

Default Value of java 8 Basic Data Types

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

1 package dierge; 2 3 public class Ceshi {4 int a; 5 double B; 6 boolean c; 7 char d; 8 float f; 9 byte e; 10 long h; 11 short j; 12 public static void main (String args []) {13 Ceshi a = new Ceshi (); 14 System. out. println ("the default integer value is:" +. a); 15 System. out. println ("default value of double precision floating point type:" +. b); 16 System. out. println ("the default value of the boolean type is:" +. c); 17 System. out. println ("the default value of the struct type is:" +. d); 18 System. out. println ("the default value of byte is:" +. e); 19 System. out. println ("the default value of the single-precision floating point type is:" +. f); 20 System. out. println ("the default value of the Short integer is:" +. j); 21 System. out. println ("the default value of a long integer is:" +. h); 22 23 24 25} 26 27}
The running result is as follows:

The default integer value is 0.
The default value of Double Precision Floating Point is 0.0.
The default value of boolean type is false.
The default value of the balanced type is:

 

 

The following conclusions are drawn:

Basic Type Default Value
Byte 0
Short 0
Int 0
Long 0L
Float 0.0f
Double 0.0d
Char '\ U000000'
Boolean False
 
   

 

 

 

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.