944,184 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 12020
  • Java RSS
Mar 1st, 2005
0

array required, but java.lang.String found

Expand Post »
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++;
}
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
phragix is offline Offline
3 posts
since Mar 2005
Mar 1st, 2005
0

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

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).
Team Colleague
Reputation Points: 1658
Solved Threads: 331
duckman
jwenting is offline Offline
7,719 posts
since Nov 2004
Mar 1st, 2005
0

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

Thank you very much. I figured it out just now by using substring instead. Thank you again for your reply.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
phragix is offline Offline
3 posts
since Mar 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: polynomials
Next Thread in Java Forum Timeline: Java3D - Problem with setting bounds





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC