How to convert integer to String
Actually I want to calculate some numbers from my database and want to show in a textfield. I know that to show any output in the textfield, need to use this variable_name.setText(var_total);.
Here is my code that I tried:
Code:
int c1 = rs.getInt("Credits1");
int c2 = rs.getInt("Credits2");
int c3 = rs.getInt("Credits3");
int c4 = rs.getInt("Credits4");
int c5 = rs.getInt("Credits5");
int getCredits = c1 + c2 + c3 + c4 + c5;
txtTotalCredits.setText(getCredits);
But this is not working. Because getCredits is an integer type.
So please tell me, how could I resolve this problem.
Thanks in advance.
Re: How to convert integer to String
txtTotalCredits.setText(""+getCredits);
or
txtTotalCredits.setText(String.valueOf(getCredits) );
or
...
or..
google has nothing to find?
Re: How to convert integer to String
May I add:
txtTotalCredits.setText(String.format("%d credits",getCredits));