Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 95 - 2617_JSSPS_C-7
P. 95

    Program 1:  Write a program to use variables and data types.

                     1   class variables_of_java
                     2       {

                     3     public static void main(String args[])
                     4           {

                     5                 byte b=127;
                     6                 short s=12345;

                     7                 int i=12345;

                     8                 long l=123456789;
                     9                 float f=234.56f;

                     10                double d=222356.3456;

                     11                char c='a';
                     12                boolean bo=true;

                     13                System.out.println("byte: "+b);

                     14                System.out.println("short: "+s);
                     15                System.out.println("int: "+i);

                     16                System.out.println("long: "+l);
                     17                System.out.println("float: "+f);

                     18                System.out.println("double: "+d);
                     19              System.out.println("char: "+c);

                     20      }

                     21  }
                     You will get the following output:

                                                                                                   Java Programming     93

| 90 91 92 93 94 95 96 97 98 99 100 |