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);  }
点赞 评论

相关推荐

仁者伍敌:牛子这些人还会点一个自动回复,boss都不带回复的
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务