我是Java Programming的新手。我想從數據庫中提取數據並在JTable中顯示它。數組常量只能在初始值設定項中使用錯誤
這是我現在的代碼。
String columns[]={"Transaction_id","User_name","Amount","Recharge_Spending","Spend_by"};
Object data[][]=new Object[200][5];
int i=0;
while(rs.next())
{
result_Transaction_id[i]=rs.getInt("f.Transaction_id");
result_User_name[i]=rs.getString("U.User_name");
data[i][5]={(Object)result_Transaction_id[i],(Object)result_User_name[i]};//This is where i get error
++i;
}
JTable View_table =new JTable(data,columns);
我想收集查詢的結果並將它們添加到指定的對象中。 但我得到以下錯誤「數組常量只能在初始化器中使用」。
我發現很多解決方案「數組常量只能用於初始化器」的錯誤,但那些不適合我的情況。
* *在哪裏,你得到的錯誤? (順便說一句,我建議你將'[]'放在類型信息的數組中:'String [] columns ='等等(聲稱這不是重複的並不會這樣。如果你提供更多的細節,而不僅僅是「但那些不適合我的情況」,這將有所幫助。) –