We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Iterator<Sheep> iter=sheepList.iterator(); int num=0; while(iter.hasNext()&&num<3){ Sheep l=(Sheep)iter.next(); // 1. if((l.name).equals("懒羊羊")){ // iter.remove(); // } // 2. if(sheepList.size()>2){ // iter.remove(); // } // 3. iter.remove(); // num++; } for(int i=0;i<sheepList.size();i++) { //Sheep l=iter.next(); System.out.println(((Sheep)(sheepList.get(i))).name); }
String[] filenames=manyfile.list(); for(int i=0;i<filenames.length;i++){ String path=filenames[i]; file=new File(manyfile,filenames[i]); FileOutputStream oos=null; String s="我真"+i; try { oos=new FileOutputStream(file); try { oos.write(s.getBytes()); //oos.write(i); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
public static void main(String[] args) { ThreadExtend h1=new ThreadExtend("一号"); ThreadExtend h2=new ThreadExtend("二号"); ThreadExtend h3=new ThreadExtend("三号"); h1.start(); h2.start(); h3.start();//Thread Thread r1=new Thread(new ThredImp1()); Thread r2=new Thread(new ThredImp1()); Thread r3=new Thread(new ThredImp1()); r1.start();//线程不能重复启动 r2.start(); r3.start();//runnable } } class ThredImp1 implements Runnable{ public String name; public void run(){ System.out.println(Thread.currentThread().getName()); } } class ThreadExtend extends Thread{ public ThreadExtend(String name){ super(name); } public ThreadExtend(){ super(); } public void run(){ for(int i=0;i<5;i++){ System.out.println("我是"+this.getName()+i); } } //runnable和thread的区别: //.1.;避免单继承的局限性2.便于资源共享
The text was updated successfully, but these errors were encountered:
No branches or pull requests
1. 作业一
2. 作业二
3. 作业三
The text was updated successfully, but these errors were encountered: