Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java remove trailing zeros from float

import java.text.DecimalFormat;


double example = 5.0; 
DecimalFormat myDF = new DecimalFormat("0.#");

//replace 'example' with the float you want to remove trailing zeros from.
System.out.println(myDF.format(example)); //output is 5

Comment

PREVIOUS NEXT
Code Example
Java :: java bukkit double jump 
Java :: java arraylist print 
Java :: java home mac 
Java :: how to get key value from json object in java 
Java :: java create list integer range 
Java :: Do not concatenate text displayed with setText. Use resource string with placeholders. 
Java :: literals in java 
Java :: android studio change image on button click 
Java :: hello world in different programming languages 
Java :: java singleton implementation 
Java :: java mp3 player 
Java :: how to initialize a set in java 
Java :: function in java 
Java :: java get all directories in path 
Java :: arraylist items into string 
Java :: counting repeated characters in a string in java 
Java :: Java Create LinkedList in Java 
Java :: android imageview set image from drawable programmatically 
Java :: java while loop example 
Java :: generatedvalue spring boot 
Java :: java replaceAll ignore case 
Java :: insert element into arraylist java 
Java :: declare array of chars java 
Java :: fill two dimensional array row by row java 
Java :: java calendar add minutes 
Java :: how to return array in java 
Java :: java string to number 
Java :: pointers in java 
Java :: create array of particular length in java 
Java :: sorting java 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =