GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • C programming
  • C++ programming
  • Java programming
  • Python programming
  • HTML
  • CSS
  • Codenora IDE (opens in a new tab)
  • About us
  • Pricing
  • Contact us
  • Privacy policy
  • Terms of service
  • Refund and Cancellation

This view

  • Original page
  • New address

GeezerVison is showing www.dremendo.com — Data Types in Java Programming Language | Dremendo

  • Dremendo
  • C
  • C++
  • Java
  • Python
  • HTML
  • CSS
  • More
    • Home
    • C Tutorial
    • C++ Tutorial
    • Java Tutorial
    • Python Tutorial
    • HTML Tutorial
    • CSS Tutorial
?>
profile image
Announcements
No new announcements.
mentora icon
Java Programming Tutorial
  • Java Basic Concepts
    • Introduction
    • Variable
    • Data Types
    • Naming Conventions
    • Integer Variable
    • Long Variable
    • Short Variable
    • Byte Variable
    • Float and Double Variables
    • Character Variable
    • Boolean Variable
    • Constant Variable
    • Typecasting
  • Operators in Java
    • Operators
    • Assignment Operators
    • Arithmetic Operators
    • Relational Operators
    • Logical Operators
    • Operator Precedence
  • Input and Output in Java
    • Environment Setup
    • Program Basic Structure
    • Output
    • Input
    • Comments
  • Decision Making in Java
    • Decision Making
    • if Statement
    • if else Statement
    • if else if Statement
    • Conditional Operator
    • switch case Statement
  • Mathematical Functions
    • Mathematical Functions
  • Loops in Java
    • Loops
    • for Loop
    • while Loop
    • do while Loop
  • Arrays in Java
    • One Dimensional Array
    • Two Dimensional Array
  • String in Java
    • String
    • StringBuffer
    • StringBuilder
  • Searching in Java
    • Linear Search
    • Binary Search
  • Sorting in Java
    • Bubble Sort
    • Selection Sort
    • Insertion Sort
  • Function in Java
    • Function
    • Recursive Function
    • Function Overloading
  • OOPs in Java
    • Classes and Objects
    • Instance Variables
    • Instance Methods
    • Access Modifiers
    • Constructor
    • Static Variables
    • Static Methods
    • Inheritance
    • Interface
    • Types of Inheritance
    • Polymorphism
    • Final Class and Method
    • Abstract Class and Method
    • Wrapper Classes
  • Data Structures in Java
    • Stack
    • Queue
    • Circular Queue
    • Double Ended Queue
    • Singly Linked List
    • Doubly Linked List
    • Stack using Linked List
    • Queue using Linked List
  • Packages in Java
    • Packages
  • Exception Handling in Java
    • Exception Handling
    • User-Defined Exception
  • Thread in Java
    • Thread
    • Thread Methods
  • File Handling in Java
    • Text File Handling
    • Binary File Handling
    • Random Access File Handling

bookmark
Table of Contents

    Data Types in Java Programming Language

    In this lesson, we will learn about the Data Types in the Java programming language along with a built-in data types table.

    What is Data Type

    In the Java programming language, data types specify the type of data that a variable can hold. Each data type requires a different amount of memory and has a specific range of values.

    Video Explanation

    Click the button below to watch the explanation.

    Please wait while the video is loading....
    video image

    Understanding data types is crucial because it helps you choose the appropriate type for storing and manipulating data. Java supports the following data types given below.

    data types in Java programming language
    • The short name for Integer data type is int.
    • The short name for Float data type is float.
    • The short name for Double data type is double.
    • The short name for Character data type is char.

    Basic Data Types in Java

    Let's go through the basic data types in Java with simple explanations and examples.

    int (Integer)

    • Description: Store whole numbers without decimals.
    • Memory Size: 4 bytes.
    • Range: -2,147,483,648 to 2,147,483,647.
    Example
    int guest_count = 20;

    float (Float)

    • Description: Stores numbers with decimals (upto 7 decimal places).
    • Memory Size: 4 bytes.
    • Range: −3.4E+38 to 3.4E+38 (meaning -3.4 × 1038 to 3.4 × 1038).
    Example
    float budget = 5000.00f;
    Note

    Here f is used to denote a float type value. If no f is used in a decimal number, then the number is treated as double type value.

    double (Double)

    • Description: Stores numbers with decimals (upto 15 decimal places).
    • Memory Size: 8 bytes.
    • Range: -1.7E+308 to 1.7E+308 (meaning -1.7 × 10308 to 1.7 × 10308).
    Example
    double distance = 1263.2514376;

    char (Character)

    • Description: Stores a single character within single quotes.
    • Memory Size: 2 byte.
    • Range: 0 to 65535.
    Example
    char grade = 'A';

    Storage Size and Range of Built-in Data Types in Java

    Data Type Storage Size Range
    boolean JVM-dependent (typically 1 byte) true or false
    byte 1 byte -128 to 127
    char 2 bytes 0 to 65535
    short 2 bytes -32,768 to 32,767
    int 4 bytes -2,147,483,648 to 2,147,483,647
    long 8 bytes -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
    float 4 bytes −3.4E+38 to 3.4E+38 (upto 7 decimal digits)
    double 8 bytes -1.7E+308 to 1.7E+308 (upto 15 decimal digits)
    Note

    Although a boolean conceptually represents 1 bit, in practice, it usually takes 1 byte (8 bits) in Java due to memory alignment and JVM constraints.

    Test Your Knowledge

    Attempt the questions in the exercise to check whether you have understood the lesson clearly.

    Exercise
    Test Your Knowledge
    Previous Next

    We care about your privacy

    Dremendo uses cookies and similar technologies that are necessary for the site to work properly, understand how you interact with our website, and measure the effectiveness of our marketing. By clicking Accept All, you consent to the use of non-essential cookies and similar technologies for analytics, advertising, and ad measurement, as described in our Privacy Policy.

    Cookie Preferences

    Choose which types of cookies Dremendo may use.

    Necessary Cookies

    Required for essential website functionality and security.

    Allow
    Analytics Cookies

    Help us understand how visitors use Dremendo.

    Allow
    Marketing Cookies

    Help us measure advertising performance and understand interactions with our advertisements.

    Allow
    Mentora Question Asked: 0 / 20

    Hi, I’m Mentora!

    I’m your personal AI tutor from Dremendo. Ask me anything, and I’ll help you understand it in a simple and easy way.

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.