AgerNic.com
WEB DEVELOPER SITE, HTML, CSS, PHP, SQL
HTML Tutorial

Java Data Types


Java Tutorial » Java Data Types

Example:
int my_Number = 27; // Integer
float my_Float_Number = 34.98f; // Floating point number
char my_Letter = 'E'; // Character
boolean my_Bool = false; // Boolean
String my_Text = "Tutorial"; // String
Data types are divided into two groups:

1. Primitive data types - includes: byte, int, short, float, double, long, boolean and char
2, Non-primitive data types - such as Classes, String and Arrays

Primitive Data Types


There are eight primitive data types in Java:

byte -1 byte - numbers from -128 to 127
short -2 bytes - numbers from -32,768 to 32,767
int - 4 bytes - numbers from -2,147,483,648 to 2,147,483,647
long - 8 bytes - numbers from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
float - 4 bytes - fractional numbers - storing 6 to 7 decimal digits
double - 8 bytes - fractional numbers - for storing 15 decimal digits
boolean -1 bit - true or false values
char - 2 bytes - a single character/letter or ASCII values


Integer Types


Byte

The byte data type, how we told you, can store numbers from -128 to 127. We use this way to save memory when you are certain the value it is between or equal: -128 and 127

Example:
byte my_Number = 100;
System.out.println(my_Number);


Short

The short data type store numbers between or equal: -32768 to 32767:

Example:
short my_Number = 4855;
System.out.println(my_Number);


Int

The int data type can store numbers between or equal -2147483648 to 2147483647.

Example:
int my_Number = 485566763;
System.out.println(my_Number);


Long

The long data type can store numbers between or equal -9223372036854775808 to 9223372036854775807.

Example:
long my_Number = 23372036854775808L;
System.out.println(my_Number);
Note: you should end the value with "L":


Floating Point Types

We use a floating point type when you need a number with a decimal, as 7.98 or 2.71828182845( The mathematical constant e is a transcendental irrational number).
Float data type store fractional numbers btween 3.4e−038 to 3.4e+038.
Example:
float my_Number = 4.85f;
System.out.println(my_Number);
Note: you should end the value with "f"::


Double

Double data type store fractional numbers between 1.7e−308 to 1.7e+308.
Example:
double my_Number = 3.85d;
System.out.println(my_Number);
Note: you should end the value with "d":




Java Data Types, size, range, exercises, trable, oracle, sizes, bits, integer, hackerrank solution
Java Data Types - java

Online Editor
ONLINE EDITOR

news templates


COLOR PICKER

news templates
This tool makes it easy to create, adjust, and experiment with custom colors for the web.


HTML Templates
news templates
Magnews2 is a modern and creative free magazine and news website template that will help you kick off your online project in style.


CSS HTML Layout
news templates
Find here examples of creative and unique website layouts.


Free CSS HTML Menu
news templates
Find here examples of creative and unique website CSS HTML menu.


0
Online Editor
ONLINE EDITOR

news templates


COLOR PICKER

news templates
This tool makes it easy to create, adjust, and experiment with custom colors for the web.


HTML Templates
news templates
Magnews2 is a modern and creative free magazine and news website template that will help you kick off your online project in style.


CSS HTML Layout
news templates
Find here examples of creative and unique website layouts.


Free CSS HTML Menu
news templates
Find here examples of creative and unique website CSS HTML menu.


HTML Image tag, code...
How to code in HTML...
HTML text tag...
HTML text, how to display...
Container responsive styles...
HTML container tag...
HTML container...
Send forgot password by mail or message ...
PHP MySQL simple login system...
Check for duplicate username live or ema...
How to create simple search engine using...
Diseño de sitio web CSS Layout...
Diseño de caja flexible CSS3...
Botones en CSS...
ID y Clase, Diferencias entre Class e Id...
Esquina redondeada CSS...
Tamaño de caja css box-sizing: border-b...
Alineación CSS...
Altura y Anchura CSS...
Bordes CSS...