?
Solved

Convert single digit to double digit

Posted on 2009-12-22
4
Medium Priority
?
878 Views
Last Modified: 2012-05-08
Hi
  I want to convert single digit integer to double digit. Is there any simple method?
I want output like
 0  -00
1- 01
11- 11

Thanks
Karan
0
Comment
Question by:Manish
  • 2
  • 2
4 Comments
 
LVL 11

Author Comment

by:Manish
ID: 26107151
double digit string will do.
0
 
LVL 24

Accepted Solution

by:
sciuriware earned 300 total points
ID: 26107665
String.format("%02d", i);  // Where 'i' is the integer.

;JOOP!
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 26107678
Likewise: output.printf("%02d", i);

Assuming 'output' is a PrintWriter object or such.

;JOOP!
0
 
LVL 11

Author Closing Comment

by:Manish
ID: 31669110
Thanks.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses
Course of the Month13 days, 22 hours left to enroll

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question