Primitieve numerieke datatypen

Introductie tot Java

Jim White

Java Developer

Primitieve types

Tabel met primitieve types - byte, short, int, long, float, double, char en boolean

Introductie tot Java

Numerieke primitieve types

byte, short, int, long, float en double gemarkeerd als focus van deze video

Introductie tot Java

Primitives voor gehele getallen - int

int slaat gehele getallen op tot twee miljoen

Introductie tot Java

long, short en byte

Tabel met long (tot een triljard), short (tot 30000) en byte (tot 128)

Introductie tot Java

int is de voorkeurs-primitive

int wordt meestal gebruikt

Introductie tot Java

double

double ondersteunt tot 16 decimalen

Introductie tot Java

float

float slaat tot 7 decimalen op

Introductie tot Java

double is de primitive voor kommagetallen

double wordt vaker gebruikt

Introductie tot Java

Primitives declareren - int

int declareren: int intEx = 123456

Introductie tot Java

Primitives declareren - int, double, short, byte

double-, short- en byte-variabelen op dezelfde manier definiëren

Introductie tot Java

Primitives declareren - float en long

Syntax voor float en long vereist een F/f of L/l aan het einde

Introductie tot Java

Numerieke primitives in actie

class PrintlnAsCalculator {
  public static void main(String[] args) {

    int x = 60000;
    byte y = 1;
    short z = 300;
    long w = 20000000L;

    System.out.println(x + y + z + w);
  } 
}
20060301
class PrintlnAsCalculator {
  public static void main(String[] args) {

    double pi = 3.1415926535;
    float half = 0.5F;

    System.out.println(pi + half);
  }
}

$$

3.6415926535
Introductie tot Java

Laten we oefenen!

Introductie tot Java

Preparing Video For Download...