Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 3

Data types

Primitive data types -


byte, short, int, long, float, double, boolean 
and char.
These are predefined in Java.

Non-primitive data types - String, Arrays,


Classes.
Type Casting
 Widening Casting (automatically) -
converting a smaller type to a larger type
size
byte -> short -> char -> int -> long -> float -
> double
 Narrowing Casting (manually) - converting
a larger type to a smaller size type
double -> float -> long -> int -> char -
> short -> byte
Arrays
Arrays are used to store multiple values in a
single variable
String[] animals =
{“Dog", “Cat", “Cow", “Pig"};

Multidimensional array
int[][] myNumbers = { {1, 2, 3, 4},
{5, 6, 7} };

You might also like