search
HomeJavaJavagetting StartedWhat are the eight basic data types in java

What are the eight basic data types in java

Jan 15, 2021 pm 03:04 PM
javaBasic data types

The eight basic data types in Java are: 1. byte; 2. short; 3. int; 4. long; 5. float; 6. double; 7. char; 8. boolean.

What are the eight basic data types in java

The operating environment of this article: windows10 system, java 1.8, thinkpad t480 computer.

(Learning video sharing: java video tutorial)

Detailed introduction:

The 8 basic data types in Java, their names, number of digits , default value, value range and examples are shown in the following table:

What are the eight basic data types in java

Example verification:

package com.ce.test;

class Test {
    static byte b;
    static short s;
    static int i;
    static long l;
    static float f;
    static double d;
    static char c;
    static boolean bo;

    public static void main(String[] args) {

      System.out.println("byte的大小:"+Byte.SIZE
              +";默认值:"+b
              +";数据范围:"+Byte.MIN_VALUE+" - "+Byte.MAX_VALUE);

      System.out.println("short的大小:"+Short.SIZE
              +";默认值:"+s
              +";数据范围:"+Short.MIN_VALUE+" - "+Short.MAX_VALUE);

      System.out.println("int的大小:"+Integer.SIZE
              +";默认值:"+i
              +";数据范围:"+Integer.MIN_VALUE+" - "+Integer.MAX_VALUE);

      System.out.println("long的大小:"+Long.SIZE
              +";默认值:"+l
              +";数据范围:"+Long.MIN_VALUE+" - "+Long.MAX_VALUE);

      System.out.println("float的大小:"+Float.SIZE
              +";默认值:"+f
              +";数据范围:"+Float.MIN_VALUE+" - "+Float.MAX_VALUE);

      System.out.println("double的大小:"+Double.SIZE
              +";默认值:"+d
              +";数据范围:"+Double.MIN_VALUE+" - "+Double.MAX_VALUE);

      System.out.println("char的大小:"+Character.SIZE
              +";默认值:"+c
              +";数据范围:"+Character.MIN_VALUE+" - "+Character.MAX_VALUE);

      System.out.println("boolean的大小:"+Byte.SIZE
              +";默认值:"+bo
              +";数据范围:"+Byte.MIN_VALUE+" - "+Byte.MAX_VALUE);

    }
}

The output result on the console is as shown below:

What are the eight basic data types in java

Related recommendations: java introductory tutorial

The above is the detailed content of What are the eight basic data types in java. For more information, please follow other related articles on the PHP Chinese website!

Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use