Reputation: 747
I don't know what's happening with my code. I can't seem to figure out why an array is giving me this error. The line is String line[] = aryLines[];
specifically aryLines[];
My Code:
public void interpretGpl(String aryLines){
System.out.println("Interpreting");
String line[] = aryLines[];
String tempString[] = null;
int tempInt[] = null;
int i = interCount;
boolean isInt;
boolean storeValue = false;
Upvotes: 1
Views: 4185
Reputation: 6675
aryLines
is declared as a String. It is not an array. Contrariwise, line
is an array. It is not a String. The thing on the right side of the = operator has to be assignable to the thing on the left side of the = operator, and Strings and arrays are completely different things.
It could be that you've chosen the wrong type for one of these variables and you wanted them to both be Strings, or both be arrays of Strings.
If the types are correct, you'll have to figure out what you wanted aryLines[]
to do, and how to do it.
Upvotes: 1
Reputation: 425128
I assume that aryLines
is a String that contains lines of text separated by linefeeds. Here's the code you need for that:
public void interpretGpl(String aryLines) {
String line[] = aryLines.split("\n");
Upvotes: 3
Reputation: 7302
What are you even trying to do here? Do you want line
to be an array with only the string aryLines
in it? In that case:
String line[] = {aryLines};
is what you need to do.
aryLines[]
by itself kind of means nothing. []
is used only in conjunction with datatypes to represent an array of that datatype. aryLines
isn't a datatype, it is the data.
Upvotes: 1