Sanjana
asked

Expert
Sarthak Baral answered
Good question! To print double values in Java, you can use the same `System.out.println()` method that you've already seen.
Just like with integers, you can write a double value directly without using quotation marks, but you should remember to include a decimal point. Hereās an example:
class Main {
public static void main(String[] args) {
System.out.println(3.14);
}
}Output
3.14In this case, `3.14` is a double value, and it prints out just like the integer examples. If you want to print multiple values, you can do that in a single `println` statement as well:
System.out.println(3.14 + " and " + 2.71);
Output
3.14 and 2.71Hope this helps! Let me know if you have more questions.
Java
This question was asked as part of the Learn Java Basics course.
Our Experts
Sudip BhandariHead of Growth/Marketing
Apekchhya ShresthaSenior Product Manager
Kelish RaiTechnical Content Writer
Abhilekh GautamSystem Engineer
Palistha SinghTechnical Content Writer
Sarthak BaralSenior Content Editor
Saujanya Poudel
Abhay Jajodia
Nisha SharmaTechnical Content Writer
Udayan ShakyaTechnical Content Writer
