0% found this document useful (0 votes)
43 views3 pages

Package Public Class Public Static Void: Out Out Out True Out False

The document discusses the primitive data types in Java, including boolean, char, string, integer, short, long, byte, float, and double. For each data type, it provides examples of declaring variables and outputs the variable values as well as the maximum and minimum possible values.

Uploaded by

Rafly Hidayat
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views3 pages

Package Public Class Public Static Void: Out Out Out True Out False

The document discusses the primitive data types in Java, including boolean, char, string, integer, short, long, byte, float, and double. For each data type, it provides examples of declaring variables and outputs the variable values as well as the maximum and minimum possible values.

Uploaded by

Rafly Hidayat
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

package BelajarJava;

public class tipedata_primitive {


public static void main (String[] args){
// tipe data di java:
// Boolean, Char, String, Integer, Short, Long, Byte, Float,
Double;

// Boolean = true / false;


// while (true){
// System.out.println("Belajar Java");
// }
boolean val = true; // hanya true / false
System.out.println("\n ======BOOLEAN======");
System.out.println("Nilai boolean val = " + val);
System.out.println("Nilai MAX = " + Boolean.TRUE);
System.out.println("Nilai MIN = " + Boolean.FALSE);

// Char (Karakter) berdasarkan ASCII


char golongandarah = 'o';
System.out.println("\n ======CHAR======");
System.out.println("Golongan darah = " + golongandarah);
System.out.println("Nilai MAX = " + Character.MAX_VALUE);
System.out.println("Nilai MIN = " + Character.MIN_VALUE);

// String (tipe data higt level) terdiri dari beberapa


Char(karakter)
String nama = " Rafly Hidayat"; // hanya true / false
System.out.println("\n ======STRING======");
System.out.println("Nilai String nama = " + nama);

// Integer (nilai satuan) rentang datanya banyak


int i = 1234567890;
System.out.println("\n ======INTEGER======");
System.out.println("Nilai Integer i = " + i);
System.out.println("Nilai MAX = " + Integer.MAX_VALUE);
System.out.println("Nilai MIN = " + Integer.MIN_VALUE);

// Short (nilai satuan)


short s = 10;
System.out.println("\n ======SHORT======");
System.out.println("Nilai Short s = " + s);
System.out.println("Nilai MAX = " + Short.MAX_VALUE);
System.out.println("Nilai MIN = " + Short.MIN_VALUE);

// Long (nilai satuan)


long l = 1000L;
System.out.println("\n ======LONG======");
System.out.println("Nilai Long l = " + l);
System.out.println("Nilai MAX = " + Long.MAX_VALUE);
System.out.println("Nilai MIN = " + Long.MIN_VALUE);

// Byte (nilai satuan)


byte b = 5;
System.out.println("\n ======BYTE======");
System.out.println("Nilai Byte b = " + b);
System.out.println("Nilai MAX = " + Byte.MAX_VALUE);
System.out.println("Nilai MIN = " + Byte.MIN_VALUE);
// Float (koma, bilangan real )
float f = 10.6f;
System.out.println("\n ======FLOAT======");
System.out.println("Nilai float f = " + f);
System.out.println("Nilai MAX = " + Float.MAX_VALUE);
System.out.println("Nilai MIN = " + Float.MIN_VALUE);

// Double (koma, bilangan real )


double d = 10.5273d;
System.out.println("\n ======DOUBLE======");
System.out.println("Nilai Double d = " + d);
System.out.println("Nilai MAX = " + Double.MAX_VALUE);
System.out.println("Nilai MIN = " + Double.MIN_VALUE);

}
}

HASIL RUN
"C:\Program Files\Java\jdk-14.0.2\bin\java.exe" "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA
2020.2.1\lib\idea_rt.jar=62587:C:\Program Files\JetBrains\IntelliJ IDEA 2020.2.1\bin"
-Dfile.encoding=UTF-8 -classpath "C:\Dev\belajar java\out\production\belajar java"
BelajarJava.tipedata_primitive

======BOOLEAN======

Nilai boolean val = true

Nilai MAX = true

Nilai MIN = false

======CHAR======

Golongan darah = o

Nilai MAX =

Nilai MIN =

======STRING======

Nilai String nama = Rafly Hidayat


======INTEGER======

Nilai Integer i = 1234567890

Nilai MAX = 2147483647

Nilai MIN = -2147483648

======SHORT======

Nilai Short s = 10

Nilai MAX = 32767

Nilai MIN = -32768

======LONG======

Nilai Long l = 1000

Nilai MAX = 9223372036854775807

Nilai MIN = -9223372036854775808

======BYTE======

Nilai Byte b = 5

Nilai MAX = 127

Nilai MIN = -128

======FLOAT======

Nilai float f = 10.6

Nilai MAX = 3.4028235E38

Nilai MIN = 1.4E-45

======DOUBLE======

Nilai Double d = 10.5273

Nilai MAX = 1.7976931348623157E308

Nilai MIN = 4.9E-324

Process finished with exit code 0

You might also like