A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

How to print different type of values in Java?
Q:

How to print different type of values in Java?

0

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.

 

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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

 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now