Advertisement
CR7CR7

DecimalFormat

Jun 13th, 2023
654
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.32 KB | None | 0 0
  1. import java.text.DecimalFormat;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) {
  5.         double number = 0.29998889;
  6.         DecimalFormat df = new DecimalFormat("#.##");
  7.         String formattedNumber = df.format(number);
  8.         System.out.println(formattedNumber); // извежда 0.3
  9.     }
  10. }
  11.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement