This is a portion of my Java code, the IDE is Eclipse. ‘Lines’ is an array of strings.
//build anchor inner text
int Count = Lines.length;
String Text = ""; //<----------Eclipse shows warning here
for (int Index=0; Index<Count; Index++) {
Text += Lines[Index];
if (Index<Count-1)
Text += "<br/>";
}
The ‘Text’ variable is declared outside the ‘for’ loop, however, it is used inside.
Eclispe shows this warning to me: “The value of the local variable Text is not used” at the declaration line of variable ‘Text’.
How could it be so? It is used inside the ‘for’ loop.
You’re assigning an empty string to your variable
Text, and then not definitely reading it (at least in the snippet shown). WhenCount == 0, or even whenCount < 1, the loop body won’t get executed, and soTextisn’t used. I presume you’ll do something withTextlater on, though?