Computer Applications

Predict the output :

double n1 = Double.parseDouble("8.0"); 
double n2 = Double.parseDouble("2"); 
System.out.println(n1 + " " + n2);

Java

Java Library Classes

3 Likes

Answer

8.0 2.0

Working

parseDouble() converts String arguments passed to it into double data type. Thus, 8.0 will be assigned to n1 and 2.0 will be assigned to n2.

The values of n1 and n2 will be printed with a space " " between them.

Answered By

2 Likes


Related Questions