ADVERTISEMENT
ADVERTISEMENT

How to print different type of values in Java?

Here, we will learn how to print different type of values using Java program? In this program, we will declare and define different variables with values and print them.

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.

Consider the program:

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

Java Basic Programs »


ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions


ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.