
Belajar atau mengingat kembali tipe data angka pada java berikut source code untuk lebih jelasnya
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Tipedataangka { | |
//bilangan bulat di java ada 4 | |
// 1.byte 8 bit | |
// 2.short 16 bit | |
// 3.int 32 bit | |
// 4.long 64 bit | |
//bilangan pecahan ada 2 | |
// 1. float 32 bit | |
// 2. double 64 bit | |
public static void main(String[] args){ | |
byte contohbyte = 127; | |
short contohshort = 9999; | |
int contohint = 999999999; | |
long contohlong =999999999; | |
float contohfloat =12.10f; //float harus menyisipkan f dibelakang nilainya | |
double contohdouble = 9999.10; | |
//bilangan bulat | |
System.out.println("contoh byte = " + contohbyte); | |
System.out.println("contoh short = " + contohshort); | |
System.out.println("contoh int = " + contohint); | |
System.out.println("contoh long = " + contohlong); | |
//bilangan pecahan | |
System.out.println("contoh float" + contohfloat); | |
System.out.println("contoh double" + contohdouble); | |
} | |
} |
0 Response to "Tipe data angka pada java"
Post a Comment