C#DataTable XML在java中等效

问题描述 投票:0回答:1
    public Dictionary<string, SomeObject> DictionaryVar= new Dictionary<string, SomeObject>();

    foreach (SomeObject ojv in DictionaryVar.Values)
    {
        if (dt.Rows.Find(obj.FirstName()) == null)
        {
            dt.Rows.Add(new object[] { false, obj.FirstName(), "", "", 0 });
        }
    }

我试过这个但它不工作..我试图通过循环浏览一些对象来填充jtable,通过检查该字段是否存在,如果它不存在,然后我将它添加到表中。

for (SomeObject bs : DictionaryVar.values()) {
    System.out.println("not getting inside");
    for (int i = 0; i < jTable1.getRowCount(); i++) {
        if (!jTable1.getValueAt(i, 1).equals(bs.FirstName())) {
            ((DefaultTableModel) jTable1.getModel()).addRow(new Object[]{false, bs.FirstName(), "", "", 0, ""});
        } else {
        }
    }

}
java dictionary hashmap equivalent
1个回答
0
投票
System.out.println("the program is outputing this");
if (ListBookMark.size() > 0) {
    for (SomeObject bs : DictionaryVar.values()) {
        System.out.println("working now");
        if (jTable1.getModel().getColumnName(1).equalsIgnoreCase(bs.GetName()) == false) {
            ((DefaultTableModel) jTable1.getModel()).addRow(new Object[]{false, bs.GetName(), "", "", 0, ""});
        }

    }
}else {
 System.out.println("bs size = " +  (ListBookMark.size() ));
}
© www.soinside.com 2019 - 2024. All rights reserved.