Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Using Java String.format, the number of digits is not enough, add 0 from the back.
Using Java String.format, the number of digits is not enough, add 0 from the back.
string str 1 = " 1 ";

decimal format df = new decimal format(" 0000 ");

string str 2 = df . format(integer . parse int(str 1));

system . out . println(str 2);

For example:

Import java.text. *;

Main class

{

Public static void main(String[] args)

{

Double d =1.23;

DecimalFormat g = new Decimalformat ("0.000000");

system . out . println(g . format(d));

}

}

Operation result 1.230000

Extended data:

Java is a multithreaded language, which supports multithreaded execution (also called lightweight process), can handle different tasks, and it is easy to design programs with clues. Java's lang package provides a Thread class, which supports methods of starting thread, running thread, stopping thread and checking thread status.

Java cue support also includes a set of synchronization primitives. These primitives are widely used synchronization schemes developed by C.A.R.Haore based on the style of supervisor and conditional variables. With the keyword synchronized, programmers can prove that some methods cannot run in a class at the same time. These methods are under the control of the monitoring program to ensure that the variables are kept in a consistent state.

Baidu encyclopedia -Java