Home java How to convert int to String?

How to convert int to String?

Author

Date

Category

For example,

int a = 6;
String b = (String) a; //does not work

Need to receive

b = "6"

Answer 1, authority 100%

int a = 6;
String b = String.valueOf (a);

Answer 2, authority 11%

1st way simple

int a = 4;
String b = a + "";

2nd method

int e = 6;
String tt = String.valueOf (e);

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions