Developer community
0 votes
1.2k views
asked by Expert (11.4k points) 14 22 29 | 1.2k views

1 Answer

0 votes
If you precede the %x format specifier with a #, the hexadecimal number will be printed with a 0x prefix.
 
import java.util.Formatter;
public class Main {
  public static void main(String args[]) {
    Formatter fmt = new Formatter();
    fmt.format("%#X", 1); 
    System.out.println(fmt);
  }
}
The output:
0X1
 
 
answered by Advisor (8.4k points) 10 15 18

Related questions

0 votes
1 answer
asked by felin Advisor (8.4k points) 10 15 18 | 27 views
0 votes
1 answer
asked by taye Sr Member (5k points) 7 9 12 | 1.1k views
0 votes
1 answer
asked by sunny Expert (11.4k points) 14 22 29 | 1.3k views
0 votes
1 answer
asked by sunny Expert (11.4k points) 14 22 29 | 922 views
0 votes
1 answer
asked by rock Expert (15k points) 15 23 31 | 83 views
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

Categories


C Books Guide and List
C++ Books Guide and List
Best Java Books

3.8k questions

4k answers

117 comments

10.7k users

3,751 questions
4,046 answers
117 comments
10,709 users