
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
The # format flag in Java
Apply the # flag to the %o, %x, %e, and %f format specifiers. If you want to display the hexadecimal number with a 0x prefix, then precede the %x specifier with #.
Preceding the %x specifier with a #, the hexadecimal number will be printed with a 0x prefix.
Let us see an example wherein $e is used. It includes a decimal point, even if the decimal digits are not present −
Example
import java.util.Formatter; public class Demo { public static void main(String args[]) { Formatter f = new Formatter(); System.out.println(f.format("%#e", 5F)); } }
Output
5.000000e+00
Advertisements