1

I have an array that contains number value and a String. I want convert that array into double. I have tried this:

int tableStringLength=tableString.length;
double [][]tableDouble= null;

for(int i=0; i<tableStringLength; i++) {
    for(int j=0; j<tableStringLength; j++) {
        tableDouble[i][j]= Double.parseDouble(tableString[i][j]);
    }
}

but it returns nothing, not null or zero when I try to display in screen.

1
  • I understand that tableString is an array of String that are actually numbers , is it ? Commented Jul 14, 2012 at 5:46

2 Answers 2

3

You didn't instantiate the double array:

double[][] tableDouble = new double[tableStringLength][tableStringLength];
Sign up to request clarification or add additional context in comments.

1 Comment

Does tableString have any values? Are you able to print tableString values?
2

thanks for all answer pals, but after i ask to my friend, she suggested to use

tableDouble[i][j]= Double.valueOf(tableString[i][j]).doubleValue();

and it works :)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.