Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

array with null elements printing into text area

Status
Not open for further replies.

cathiec

Programmer
Oct 21, 2003
139
IE
I have the following code in actionPerformed:

if(e.getSource()==btShowQuestions){

for(int j=1;j<=gQuestionsAcross.length;j++){

taQuestionArea.append(gQuestionsAcross[j]);
taQuestionArea.append(&quot;\n&quot;);

}


}
when the button btShow Questions is clicked the elements of the array gQuestionsAcross are printed into the text area taQuestionsAcross. My problem is that some of the elements of the array are null and a blank line is printed for each of these null elements. Is they any condition that i can use so that only elements of the array that contain a string are printed thus leaving no blank lines in the text area?
 
for(int j=1;j<=gQuestionsAcross.length;j++){
if (gQuestionsAcross[j] != null) {
taQuestionArea.append(gQuestionsAcross[j]);
taQuestionArea.append(&quot;\n&quot;);
}

}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top