| |

VerySource

 Forgot password?
 Register
Search
View: 691|Reply: 2

How to convert numeric to string in JAVA

[Copy link]

2

Threads

5

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 United States

Post time: 2020-2-6 20:00:01
| Show all posts |Read mode
How to convert a numeric type to a string in Java? What function is used?
For example, turn 1 into "01"
Reply

Use magic Report

0

Threads

14

Posts

13.00

Credits

Newbie

Rank: 1

Credits
13.00

 China

Post time: 2020-3-28 19:15:01
| Show all posts
The very disgusting method is as follows (please ask for good methods):
int i = 9;
String strTemp = "";
if (i <= 9)
strTemp = "0" + i;
else
strTemp = "" + i;
System.out.print (strTemp);
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-3-29 12:15:02
| Show all posts
String.valueOf (123); Simpler 123+ ""
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list