clone(): ArrayList.clone() I thought does a shallow copy

后端 未结 6 1823
别那么骄傲
别那么骄傲 2020-11-29 05:59
ArrayList a=new ArrayList();
a.add(5);
ArrayList b=(ArrayList)a.clone();
a.add(6);
System.out.println(b.t         


        
6条回答
  •  北荒
    北荒 (楼主)
    2020-11-29 06:27

    can't we select dynamically at what position we want to add the string like this

    int r=k.nextInt();
    Integer i6=new Integer(r);
    System.out.println("Enter the address");
    String p6=k.nextLine();
    ar3.add(i6,p6);
    

    its not excuting the after reading the integer

提交回复
热议问题