I'm working on an app and have come into a problem with part of the code:
First here it is:
FileReader languagefile;
BufferedReader bufferlan;
String[] codeName = new String[700];
String[] translation = new String[700];
int translationNum = 0;
int codeNum = 0;
int numberLine = 0;
try
{
languagefile = new FileReader(completefile);
bufferlan = new BufferedReader(languagefile);
String temp = null;
while((temp=bufferlan.readLine()) != null)
{
if(((numberLine/2) % 2) == 1)
{
codeName[codeNum] = bufferlan.readLine();
codeNum ++;
}//end if
else
{
translation[translationNum] = bufferlan.readLine();
translationNum ++;
}//end else
}//end while
bufferlan.close();
languagefile.close();
JLabel title = new JLabel(text);
Object[][] data;
int rowNum = 0;
while(rowNum <= codeNum)
{rowNum = 0;
data[rowNum][0] = codeName[rowNum];
data[rowNum][1] = translation[rowNum];
}
String[] columnNames = {"Code Name","Translation"};
JTable table = new JTable(data, columnNames);
JScrollPane scrollPane = new JScrollPane(table);
LanguagePanel.add(title);
LanguagePanel.add(scrollPane);
}//end try
catch( IOException e )
{
System.out.println(e);
}
return LanguagePanel;
}
It is when I try to compile my code that I get these two errors:
variable data might not have been initialized
data[rowNum][0] = codeName[rowNum];
& the same for this line:
JTable table = new JTable(data, columnNames);
The arrow below them points first to the codeName variable then secondly to
the columnNames variable.
Please any help would be greatly apprecaited :)
BTW the two variable completefile and languageFile are set up further up the
code.