- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
DecimalFormat("0.######E0") in Java
DecimalFormat is a concrete subclass of NumberFormat that formats decimal numbers. Let us set DecimalFormat("0.######E0") and use the format() method as well −
new DecimalFormat("0.######E0").format(298757)
Since, we have used DecimalFormat class in Java, therefore importing the following package in a must −
import java.text.DecimalFormat;
The following is the complete example −
Example
import java.text.DecimalFormat; public class Demo { public static void main(String[] argv) throws Exception { System.out.println(new DecimalFormat("0.######E0").format(298757)); System.out.println(new DecimalFormat("0.######E0").format(19988)); } }
Output
2.98757E5 1.9988E4
- Related Articles
- DecimalFormat("##E0") in Java
- DecimalFormat("###E0") in Java
- Format double with new DecimalFormat("0.#####E0") in Java
- DecimalFormat(abc#) in Java
- DecimalFormat("000000E0") in Java
- DecimalFormat("00.00E0") in Java
- DecimalFormat("00E00") in Java
- DecimalFormat("000E00") in Java
- DecimalFormat("0000000000E0") in Java
- Java Program to format hour in H (0-23) format in Java
- Infinity or exception in Java when divide by 0?
- Numbers in Java (With 0 Prefix and with Strings)
- Replace Negative and Positive Matrix Elements with 0 & 1 in Java
- Java Program to display hour in K (0-11 in AM/PM) format
- Check if Array is Free From 0 and Negative Number in Java

Advertisements