获取输出为[Ljava.lang.Object; @ 1d4481

时间:2017-03-30 05:49:25

标签: java

我正在尝试将一组月份和日期打印到表的列中...它显示{Ljava.lang.Object; @ 1d4481错误..但是当我尝试将行打印到行时它工作正常..我搜索了stackover线程,发现了类似的qustion,它说对象类型的东西.. 这是我的表属性

enter image description here

这是我的代码

    Calendar calendar = Calendar.getInstance();
    //System.out.println("The current date is : " + calendar.getTime());
    System.out.println("The current date is : " + calendar.getTime()); 

    calendar.set(1995, 10, 2);
    for(int i=0; i<2 ; i=i+1){
    calendar.add(Calendar.DATE, 1);
    //System.out.println(" Dates later: " + calendar.getTime());
    System.out.println(" Dates later: " + calendar.get(Calendar.MONTH)+"/"+calendar.get(Calendar.DATE));

    //System.out.println(" Dates later: " + Arrays.toString(calendar.get(Calendar.MONTH).toArray())+"/"+Arrays.toString(calendar.get(Calendar.DATE).toArray()));


    SimpleDateFormat dFormat = new SimpleDateFormat("yyyy-MM-dd");
    String date = dFormat.format(jDateChooser1.getDate()); 
    DefaultTableModel model = (DefaultTableModel) jTable1.getModel();
    //model.addRow(new Object[]{calendar});

     //model.addRow(new Object[]{calendar.get(Calendar.MONTH)+"/"+calendar.get(Calendar.DATE)});  
     model.addColumn(new Object[]{calendar.get(Calendar.MONTH)+"/"+calendar.get(Calendar.DATE)});
    }

1 个答案:

答案 0 :(得分:0)

您可以尝试将行放置为:model.addRow();并通过此方法传递具有所有列值的String数组。

请参阅链接:What is the easiest way to display the contents of an ArrayList of Objects in a JTable?