0

Let's suppose the following inputs for Java 8 method:

String a = "12345678";

String b = "123456";

What's the most elegant and safe way to have this as a result?

a -> "0012345678";
b -> "0000123456";

I want to have a fixed size String variables that are completed with zeros to the left.

Zendie
  • 1,176
  • 1
  • 13
  • 30
OneNoOne
  • 587
  • 7
  • 23
  • there is a multitude of ways to do so. you ask about an opinion. This is not a forum for this. – Serge Sep 12 '19 at 01:24
  • There is a bunch of ways to this ugly and unsafe. I want one maybe already provided by language or some known framework so I can trust. – OneNoOne Sep 12 '19 at 01:29
  • is this only for numbers (integers) ? I used to have one util for this for one of my project before. – ralphgabb Sep 12 '19 at 03:25

0 Answers0