Given different type of values and we have to print them on output screen.
In this program, we are going to declare and define some of the different type of variables and then will print them using System.out.println() method.
class j2{
public static void main(String args[])
{
int num;
float b;
char c;
String s;
//integer
num = 100;
//float
b = 1.234f;
//character
c = 'A';
//string
s = "Hello Java";
System.out.println("Value of num: "+num);
System.out.println("Value of b: "+b);
System.out.println("Value of c: "+c);
System.out.println("Value of s: "+s);
}
}
Output
Value of num: 100
Value of b: 1.234
Value of c: A
Value of s: Hello Java
Consider the program:
Output