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

PREVIOUS NEXT
Code Example
Java :: java return tuple 
Java :: json to hashmap java stream 
Java :: java install in fedora 
Java :: charcodeat java 
Java :: convert arraylist to csv file java 
Java :: UTC in Java 
Java :: filtering out unique values from a list in java 
Java :: java print 
Java :: Java Create LinkedList in Java 
Java :: volley dependency 
Java :: dark mode app android studio 
Java :: spring.jpa.properties.hibernate 
Java :: java secretkey 
Java :: how to initialize array in java 
Java :: byte array to file java 
Java :: maven paper 
Java :: main method 
Java :: java get number out of string 
Java :: fill two dimensional array java 
Java :: How to build a Sudoku solver, in Java? 
Java :: template competitive programming java 
Java :: from date to string 
Java :: java localtime 
Java :: sum of array elements java 
Java :: create array of particular length in java 
Java :: android iinput edit text password icon change 
Java :: java priority queue 
Java :: java using .indexof to fin a space 
Java :: map java 
Java :: Caused by: java.lang.ClassNotFoundException 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =