import java.util.ArrayList; public class Notepad {  public String item;  public ArrayList list;  public Notepad() {   list=new ArrayList();   this.item=null;  }  public Notepad(String item){   list=new ArrayList();   list.add(item);   this.item=item;  }   public void add(String item) {   list.add(item);  };  public void check() {   System.out.println(list);  };  public void check(int index) {   if(index>getcount()) {System.out.println("超出记录范围");}   else System.out.println(index+"位置处的记录是:"+list.get(index));}  public int getcount() {   return list.size();  }  public void dele(String item) {list.remove(item);};  public static void main(String [] args) {   Notepad note=new Notepad("hello");   note.add("hi");   int cc=note.getcount();   System.out.println(cc);   note.check();   note.dele("hi");   note.add("I am");   note.add("Lemon");   note.check();   note.check(2);   note.check(10);  }
点赞 评论

相关推荐

牛至超人:哈工大已经很棒了,不需要加括号了,然后咋没有实习经历呢?火速趁寒假整一段实习,导师不让就狠狠肘击
投了多少份简历才上岸
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务