user828948
user828948

Reputation: 151

convert int to string in android?

I want to store 1 to 110 in string array variable, when i tried am getting null pointer exception.

String age[];
for(int i=0;i<=101;i++){
  age[i]=Integer.toString(i);
}

Upvotes: 0

Views: 4975

Answers (5)

Nikunj Patel
Nikunj Patel

Reputation: 22066

You got error because you haven't initialized it :

String[] age = new String[111];

Upvotes: 1

user2177333
user2177333

Reputation: 21

String abc = String.valueOf(int);

Upvotes: 2

Vineet Shukla
Vineet Shukla

Reputation: 24021

try this:

String[] age = new String[102];
String.valueOf(int value);

Upvotes: 2

Lukas Knuth
Lukas Knuth

Reputation: 25755

You'll need to initialize the String-array first:

String[] age = new String[110];

Upvotes: 4

Tobias
Tobias

Reputation: 9380

You have to create the String array first:

String[] age = new String[111];

Upvotes: 1

Related Questions