top of page
Caută
  • Poza scriitoruluioanaunciuleanu

Data types in JAVA



1. Byte

Example:

byte myByte = 10;


The default value for byte is 0.

The values are in the range: -128 .. -1,0,1, .. 127.

Size : 8 bits.


2. Short

Example:

short myShort = 1879;


The default value for short is 0.

The values are in the range: -32,768 .. -1,0,1, .. 32,767 .

Size : 16 bits.


3. Int

Example:

int myInt = -48592;


The default value for int is 0.

The values are in the range: -2147483648 ... 2147483647.

Size : 32 bits.


4. Long

Example:

long myLong = 100L;


The default value for long is 0L.

The values are in the range: -2^63 ... 2^63 -1.

Size : 64 bits.


5. Float

Example:

float myFloat = 7.36f;


The default value for float is 0.0f .

It is not precise.

Size : single-precision 32-bit IEEE 754 floating point


6. Double

Example:

double myDouble = 200.3d;


The default value for double is 0.0d .

Size : 64-bit IEEE 754 floating point


7. Char

Example:

chair myChar = 'a';


The default value for char is '\u0000' or 0, which is the minimum.

The maximum value is '\uffff' (or 65,535).

Char is a single 16-bit Unicode character.


8. Boolean

Example:

boolean myBoolean = true;


The default value for boolean is false.

The possible values are true and false.

Boolean data type represents one bit of information.


9. String

Example:

String myString = "Hello";


The default value for String, or any object is null.

String, meaning character strings is an object via the java.lang.String class.

String objects are immutable, which means that once created, their values cannot be changed.

7 afișări0 comentarii

Postări recente

Afișează-le pe toate

Weighted Job Scheduling in JAVA

You receive a list of jobs that have three elements: start time, finish time and profit. You have to schedule the jobs with no overlapping, in order to obtain the maximum profit. Solution: 1. static

Tiling Problem in JAVA

You can use a board that is 2 x n size. The tiles are of size 2 x 1. Count the number of ways to tile the board. Tiles can be placed vertically 2 x 1 or horizontally as 1 x 2. Solution: 1. static

bottom of page