array required, but java.lang.String found

Reply

Join Date: Mar 2005
Posts: 3
Reputation: phragix is an unknown quantity at this point 
Solved Threads: 0
phragix phragix is offline Offline
Newbie Poster

array required, but java.lang.String found

 
0
  #1
Mar 1st, 2005
I declared mNodes as a String Array and try to assign a value to it with sTemp which is a String as well...but there's an error occurred as: "array required, but java.lang.String found". I don't understand why. I need some suggestion please. Thank you.

String sTemp;
String mNodes[][] = new String [noNodes][6];
for (int iRow = 4; iRow < noNodes + 4; iRow++) {
sTemp = ain.get(iRow).toString();
int mRow = 0;
int mCol = 0;
for (int iCol = 0; iCol < 12; iCol+=2) {
mNodes[mRow][mCol] = sTemp[iCol]; // error occurred here
System.out.println(mNodes[mRow][mCol]);
mCol++;
}
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,145
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 212
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: array required, but java.lang.String found

 
0
  #2
Mar 1st, 2005
A String is not an array of characters in Java (in this Java differs from for example C and Pascal).

The compiler is quite correct and extremely helpful in pointing out that you're trying to use a String as if it were an Array (yes, arrays are also objects).
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 3
Reputation: phragix is an unknown quantity at this point 
Solved Threads: 0
phragix phragix is offline Offline
Newbie Poster

Re: array required, but java.lang.String found

 
0
  #3
Mar 1st, 2005
Thank you very much. I figured it out just now by using substring instead. Thank you again for your reply.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC