我有一个程序,里面有一个类,然后在那个类中有另一个类,在那个类中有一个方法。我正在尝试在类中调用该方法。基本上:方法在 B 类中,而 B 类在 A 类中。
Class A
Class B
Method
B类:
class MyTableModel extends AbstractTableModel
{
public void getLibraryData () throws IOException
{
BufferedReader reader = new BufferedReader (new FileReader ("" + username [0] + ".txt"));
BufferedWriter writer = new BufferedWriter (new FileWriter ("" + username [0] + ".txt", true));
String line = null;
int count = 0;
while ((line = reader.readLine ()) != null)
{
songs [count] = line;
artists [count] = reader.readLine ();
categoryA [count] = reader.readLine ();
count++;
}
data = new Object [count] [];
for (int i = 0 ; i < count ; i++)
{
Object[] row = data [i] = new Object [3];
row [0] = songs [i];
row [1] = artists [i];
row [2] = categoryA [i];
}
}
private String[] columnNames = {"Song",
"Artist",
"Category", };
private Object[] [] data = {
};
public int getColumnCount ()
{
return columnNames.length;
}
public int getRowCount ()
{
return data.length;
}
public String getColumnName (int col)
{
return columnNames [col];
}
public Object getValueAt (int row, int col)
{
return data [row] [col];
}
public Class getColumnClass (int c)
{
return getValueAt (0, c).getClass ();
}
}
我正在尝试调用 getLibraryData()。