Primitives and Arrays
Learn about Java primitives and arrays.
Primitives
Primitive types in Java refer to different ways to store numbers:
char
: A single character, such as “A” (the letter A).
Press + to interact
public class main {public static void main(String[] args) {char hello = 'A';System.out.println(hello);}}
byte
: A number from -128 to 127 (8 bits). This is typically a way to store or transmit raw data.
Press + to interact
public class main {public static void main(String[] args) {byte num = 100;System.out.println(num);}}
short
: A 16-bit signed integer. It has a maximum value of around 32,000, precisely 32,767.
Press + to interact
public class main {public static void main(String[] args) {short num = 32212;System.out.println(num);}}
int
: A 32-bit signed integer. Its maximum is around
Create a free account to view this lesson.
By signing up, you agree to Educative's Terms of Service and Privacy Policy