Page 71 - CA_Blue( J )_Class9
P. 71
Dynamic Initialisation
Assigning values to variables during runtime, often based on some logic or user input called Dynamic Initialisation.
Some examples are:
Data types Declaration Dynamic Initialisation
int int a1, a2, a3; a1=a2 + a3;
float float i1,i2,i3; i1=i2 + i3;
String String c= “India”, d= “Delhi” , e; e= c + d;
Program 13 Write a program to use variables and data types.
1 class variables_of_java
2 {
3 public static void main()
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 }
22 }
Values and Types 69

