0

hello,
i wrote a code to encrypt the 4 digit number.
i broke the number in digits and encrypted it.
It works fine. But the problem comes when first digit in output comes 0.
that time i get 3 digit number instead of 4 digit number. i want it to show 0(3 digit answer).
how can i fix the length of the output number to 4 ?

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by newack
0

Use DecimalFormat

DecimalFormat df = new DecimalFormat("0000");
      int a=23;
      System.out.println(df.format(a));
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.