Tsallaka zuwa abun ciki
Justice Tech School

Primitive Types

Java has byte, short, int, long, float, double, char and boolean. int is the default integer, double the default decimal.

Example
public class Main {
  public static void main(String[] args) {
    byte b = 100; short s = 1000; int i = 100000; long l = 10000000000L;
    float f = 1.5f; double d = 2.5; char c = 'A'; boolean ok = true;
    System.out.println(b + " " + l + " " + f + " " + c + " " + ok);
  }
}

Result

100 10000000000 1.5 A true

Exercise

Big integer type.

 big = 10000000000L;

Quiz Test

Which is the default decimal type?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.