top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to print complete double value in JAVA?

+8 votes
191 views

Here is my snippet:

public class Test {
  public static void main(String[] args) {
    Double doubleValue = 10.000;
    System.out.println(doubleValue);
  }
}
posted Feb 6, 2014 by Hiteshwar Thakur

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+3 votes
public class Test {
  public static void main(String[] args) {
    Double doubleValue = 10.000;
    System.out.println( String.format( "%.2f", doubleValue ) )
  }
}
answer Feb 11, 2014 by Asmita Agrawal
Similar Questions
+3 votes

In Java
I am using statement a += b where a is int and b is double, when I use a += b, it won't give error but in case of a = a + b it gives error, why ?

+4 votes

Design an algorithm to accept a string from the user. Count and print the number of times each character occurs in the given string. Example –
input string = "malayalam"
Output must be –
m – 2
a – 4
l – 2
y - 1

...