Minggu, 09 Oktober 2011

Program Java Menggunakan Tipe Data

Langsung saja ke kode program :

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

            byte b = 1;
            short s = 100;
            int i = 1000;
            long l = 10000;
            char c = 'a';
            float f = 3.14f;
            double d = 3.14;
            boolean t = true;
                        final double PI = 3.14;

            System.out.println ("byte " +b);
            System.out.println ("short " +s);
            System.out.println ("int " +1);
            i = 010;
            System.out.println ("int " +i+ " octal mode");
            i=0XFF;
            System.out.println ("int " +i+ " hexa mode");
            System.out.println ("long " +1);
            System.out.println ("char " +c);
            System.out.println ("float " +f);
            System.out.println ("double " +d);
            System.out.println ("boolean " +t);
            System.out.println ("PI " +PI);

}
}
Hasilnya seperti berikut :







Tidak ada komentar:

Posting Komentar