About 2,200,000 results
Open links in new tab
  1. Default Values Assigned to Primitive Data Types in Java

    Oct 1, 2024 · In Java, when a variable is declared but not initialized, it is assigned a default value based on its data type. The default values for the primitive data types in Java are as follows:

  2. Default Value of Primitive Data Types in Java

    Learn about the default values assigned to primitive data types in Java, including int, float, boolean, and more.

  3. Java program to print default values of primitive data types

    Given below is a java program that displays default values of different primitive data types like int, float, double, boolean, String. Default value means the value assigned automatically by Java …

  4. java - Getting default value for primitive types - Stack Overflow

    Aug 29, 2015 · It's possible to get the default value of any type by creating an array of one element and retrieving its first value. This way there is not need to take account for every …

  5. primitive - What are the default values for data types in Java?

    May 24, 2017 · if(person.getId()==0){} Default values for primitives in java: Data Type Default Value (for fields) byte 0 short 0 int 0 long 0L float 0.0f double 0.0d char '\u0000' boolean false …

  6. java - default values for primitives - Stack Overflow

    Nov 20, 2012 · Instance variables will be defaulted to a 'reasonable' value. Local variables will contain garbage. Read up on the topic here. for int x the default value would be 0. For primitive …

  7. Primitive Data Types (The Java™ Tutorials - Oracle

    Default Values It's not always necessary to assign a value when a field is declared. Fields that are declared but not initialized will be set to a reasonable default by the compiler. Generally …

  8. Java Data Types (Primitive) - Programiz

    There are 8 data types predefined in Java, known as primitive data types. Note: In addition to primitive data types, there are also referenced types (object type). The boolean data type has …

  9. Display Default Initial Values of DataTypes in Java

    Learn how to display the default initial values of various data types in Java. Understand the significance of default values for primitive and reference types.

  10. Java Program to get the default value of primitive data types

    Get the default value of primitive data types. These types are used for data manipulation, for example, int, float, double, boolean, etc.

Refresh