Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java float get 2 decimals

DecimalFormat df = new DecimalFormat("0.00");
String myFormattedFloat = df.format(myFloat);
Comment

print float number with only four places after the decimal point in java

import java.text.DecimalFormat;
public class code{
  public static void main(String[] args){
		double area= 12.21564315;
       	DecimalFormat df = new DecimalFormat("0.0000");
       	System.out.println("A="+df.format(area));
  }
}
Comment

how to get 2 decimal places in java

total = (double) 100 / listMember.size();
DecimalFormat df = new DecimalFormat("#.##");
String dx = df.format(total);
total = Double.valueOf(dx);
Comment

PREVIOUS NEXT
Code Example
Java :: get file extension java 
Java :: String array into LinkedList java 
Java :: java read each lines in file 
Java :: first and last digit sum java 
Java :: android save int 
Java :: print map in java 
Java :: implement graph in java example 
Java :: is prime java 
Java :: java check data type 
Java :: java days between two dates 
Java :: convert local datetime to instant java 
Java :: testException = com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field 
Java :: change color of jframe 
Java :: array to array list 
Java :: java biginteger multiply 
Java :: java random 5 digit int 
Java :: password encryption and decryption in java 
Java :: console printing in java 
Java :: size of queue in java 
Java :: android studio textbox change text 
Java :: bukkit Command sender is player 
Java :: get hashmap into array 
Java :: java print array as string 
Java :: java else nothing 
Java :: java prime numbers 
Java :: java calendar hour vs hour of day 
Java :: java random uuid 
Java :: groovy ternary operator short form 
Java :: comment in java 
Java :: java check two dates same day 
ADD CONTENT
Topic
Content
Source link
Name
8+9 =