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
1.删羊
//删除羊的三种办法 //1 顺序递增删羊 int k=sheepList.size(); for(int i=k-3;i<k;i++) { sheepList.remove(k-3); } //2 顺序递减删羊 int k=sheepList.size(); for(int i=k-1;i>=k-3;i--) { sheepList.remove(i); } //3 从后向前删 for(int i=0;i<3;i++) { sheepList.remove(sheepList.size()-1); }
2.IO文件
package javahomework; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; public class doing2 { public static void main(String[] args) { File manyfile=new File("D://testfoio"); File file = null ; try { if(!manyfile.exists()) manyfile.mkdir(); for(int i=0;i<10;i++) {file=new File(manyfile.getAbsolutePath(),"helloworld"+i+".txt"); if(!file.exists()) file.createNewFile();} } catch (IOException e) { e.printStackTrace(); } String []filenames= manyfile.list(); for(int i=0;i<filenames.length;i++) System.out.println(filenames[i]); File file_3=new File(manyfile,"helloworld_3.txt"); file_3.delete(); for(int i=0;i<=9;i++) { file =new File(manyfile,"helloworld"+i+".txt"); OutputStream os=null; try { os=new FileOutputStream(file); String s="我真"+i; try { os.write(s.getBytes()); } catch (NumberFormatException | IOException e) { e.printStackTrace(); } } catch (FileException e) { e.printStackTrace(); }finally { try { os.close(); } catch (IOException e) { e.printStackTrace(); }} } } }
比较Thread和Runnable
class othread extends Thread{ public othread(String name){ super(name); } public othread(){ super(); } public void run() { for(int i=0;i<5;i++){ System.out.println("othread"+this.getName()+i); } } } class threadexp implements Runnable{ public String name; public String getName() { return name; } public void setName(String name) { this.name = name; } @Override public void run() { // TODO Auto-generated method stub for(int i=0;i<5;i++){ System.out.println("runable"+this.getName()+i); } } }
The text was updated successfully, but these errors were encountered:
类名首字母记得大写.
Sorry, something went wrong.
No branches or pull requests
1.删羊
2.IO文件
比较Thread和Runnable
The text was updated successfully, but these errors were encountered: