I need a way to print the number as hex, as a zero line of width N, where N can be selected at runtime.
This does not work:
System.out.println(String.format("%*x", 4, 0x123))
because it’s obvious that Java does not support Using C% in% * for width format strings selected at runtime .
Any suggestions for an alternative?
int width = 4; String format = "%" + width + "x"; System.out.println(String.format(format, 0x123));
: wrysmile:
@fd also with printf
int width = 4; String format = "%" + width + "x"; System.out.printf(format, 0x123); System.out.printf("%4x", 0x123);
Use the appropriate NumberFormat.
EDIT
It is not right.
Source: https://habr.com/ru/post/1783459/More articles:WPF Validation Result - validationHighlight a variable between C and Labview? - cПримеры хороших XML-библиотек JavaScript JSON? - jsonConditional comments or IE hacks - cssProblem creating a PostGIS template database - postgisHow to make eclipse not auto-index code block - eclipsehow to find the reason for breaking the stack - chttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1783462/how-to-rewrite-python-dicts-to-get-default-values&usg=ALkJrhjXonU95oKpgE7PaAX5VWpR2p6KpgWhat are the object requirements (limitations) for storing an object in RavenDB - .netIs it possible to create an HTML 5 page from XML data? - javascriptAll Articles