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
import java.util.ArrayList; public class S111 { public static void main(String[] args) { int[] a=new int[]{1,2,3,4,5}; Sheep[] sheep=new Sheep[]{ new Sheep("喜羊羊"),new Sheep("美羊羊"),new Sheep("暖洋洋"), new Sheep("沸羊羊"),new Sheep("懒洋洋")}; System.out.println(sheep[2].getName()); ArrayList<Sheep> sheepList=new ArrayList(); sheepList.add(new Sheep("喜羊羊")); sheepList.add(new Sheep("美羊羊")); sheepList.add(new Sheep("暖洋洋")); sheepList.add(new Sheep("沸羊羊")); sheepList.add(new Sheep("懒洋洋"));
int k=sheepList.size(); for(int i=k-3;i<k;i++) { sheepList.remove(k-3); }
for(int i=0;i<3;i++) { sheepList.remove(sheepList.size()-1); }
for (int j=2;j<sheepList.size();j--) { sheepList.remove(j); j++; } for(int i=0;i<sheepList.size();i++){ System.out.println(((Sheep)(sheepList.get(i))).getName()); } } }
int j=0; Iterator it = sheepList.iterator(); for(;it.hasNext();){ if(j>1) { sheepList.remove(j); } else{ it.next(); j++; } }
import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import javax.swing.plaf.synth.SynthSeparatorUI;
public class FlieTest { public static void main(String[] args){ File manyfile=new File("D://test1"); File file; OutputStream os=null; try{ if(!manyfile.exists()){ manyfile.mkdir(); } for(int i=0;i<=10;i++){ file=new File(manyfile,"helloworld"+i+".txt"); os=new FileOutputStream(file); String s="中北大学安卓实验室"; os.write(s.getBytes()); } }catch(FileNotFoundException e) { e.printStackTrace(); }catch(NumberFormatException e) { e.printStackTrace(); }catch (IOException e) { e.printStackTrace(); } } }
public static void main(String args[]) { Thread1 s1=new Thread1(); //Thread对象s1只能开启一个线程 Thread1 s2=new Thread1(); //Thread对象s2只能开启一个线程 s1.start(); s2.start(); Thread2 t1=new Thread2(); Thread ta=new Thread(t1,"A"); Thread tb=new Thread(t1,"B"); //使用Runnable接口创建的接口使用同一个对象t1 ta.start(); tb.start(); } public class Thread1 extends Thread{ public void run(){ for(int i=0;i<5;i++){ System.out.println(Thread.currentThread().getName()+" "+i); } } } public class Thread2 implements Runnable{ public void run() { { for(int i=0;i<5;i++) { System.out.println(Thread.currentThread().getName() +" "+i); } } } }
一个Thread对象只能开启一个线程,而一个实现了Runnable接口的对象可以开启多个线程 java是单继承的,使用Runnable
The text was updated successfully, but these errors were encountered:
No branches or pull requests
1. 删羊
方法一
方法二
方法三
迭代器
2. 批量写入文件
3. Thread和Runnable区别
The text was updated successfully, but these errors were encountered: