How to add a number with leading zeros into an empty string with Java

1 Answer

0 votes
class Program {
    public static void main(String[] args) {
        int number = 98;
        
        String empty_string = String.format("%05d", number);

        System.out.println(empty_string);
    }
}



/*
run:

00098

*/

 



answered May 25, 2024 by avibootz

Related questions

...