两个arraylist中的元素可以一起添加吗?

时间:2013-12-16 06:44:50

标签: java if-statement arraylist add

无论如何我可以在List 19和List 20中同时添加元素吗?

我有两个整数形式的元素,并使用List.get我可以得到数字。但我无法将它们添加到一起,因为它们来自不同的列表和不同的if / else语句。无论如何我可以在不改变算法的情况下添加它们吗?

List11.add(driver
        .findElement(
                By.xpath("html/body/table[2]/tbody/tr/td[4]/table/tbody/tr[3]/td/table/tbody/tr[2]/td[2]/div/span"))
        .getAttribute("class"));
if (List11.get(0).equals(List10.get(0))) {

    String c = "1";
    ArrayList<String> List19 = null;
    List19 = new ArrayList<String>();
    List19.add(c);

    System.out.println(List19.get(0));
    System.out.println("Access Right add + 1point");

} else {

    String c = "0";
    ArrayList<String> List19 = null;
    List19 = new ArrayList<String>();
    List19.add(c);

    System.out.println(List19.get(0));
    System.out.println("Access Right no point will be added");
}

List12 = new ArrayList<String>();
System.out
        .println("Edit profile: "
                + driver.findElement(
                        By.xpath("html/body/table[2]/tbody/tr/td[4]/table/tbody/tr[3]/td/table/tbody/tr[3]/td[2]/div/span"))
                        .getAttribute("class"));
List12.add(driver
        .findElement(
                By.xpath("html/body/table[2]/tbody/tr/td[4]/table/tbody/tr[3]/td/table/tbody/tr[3]/td[2]/div/span"))
        .getAttribute("class"));
if (List12.get(0).equals(List10.get(0))) {

    String d = "2";         
    ArrayList<String> List20 = null;
    List20 = new ArrayList<String>();
    List20.add(d);

    System.out.println(List20.get(0));
    System.out.println("Access Right add + 2point");
} else {

    String d = "0";
    ArrayList<String> List20 = null;
    List20 = new ArrayList<String>();
    List20.add(d);

    System.out.println(List20.get(0));
    System.out.println("Access Right no point will be added");
}

0 个答案:

没有答案