Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

how to set 2 decimal places in java

DecimalFormat df = new DecimalFormat();
df.setMaximumFractionDigits(2);
System.out.println(df.format(decimalNumber));
Comment

specify decimal places java

double test = 12.15;
DecimalFormat df = new DecimalFormat("#.0");
System.out.println(df.format(test)); // Console: 12.2
// # - prints a digit if provided, nothing otherwise
// . - indicates where to put the decimal seperator
// 0 - prints a digit if provided, 0 otherwise
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

java 2 decimals

double res = Math.round(a * 100) / 100;
Comment

PREVIOUS NEXT
Code Example
Java :: clear array java 
Java :: java run system command 
Java :: java version 
Java :: loop list java 
Java :: android studio list of strings 
Java :: prime number between given range in java 
Java :: java sort list 
Java :: java generate secure random password 
Java :: java or symbol 
Java :: check if all values are same in list java 
Java :: how to open an activity from a fragment 
Java :: sorting char array in java 
Java :: how to add to a file in java 
Java :: java leap year expression 
Java :: java how to print a string[] 
Java :: how to add elements to an array in java dynamically 
Java :: android studio Clearing shared preferences; 
Java :: android alertdialog setSingleChoiceItems 
Java :: bufferedinputstream to byte array 
Java :: h2 database spring boot 
Java :: how to iterate list of string array in java 
Java :: runnable interface in java 
Java :: java how to check string is number 
Java :: how to detect device javascirpt 
Java :: map interation in java 
Java :: Get the last Friday of a month in Java 
Java :: java variable in string 
Java :: java thread class sleep 
Java :: transformer un string en double java 
Java :: string to char in java 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =