Skip to content
New issue

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

Java1-崔雨豪1407094234 #19

Open
cyhbrilliant opened this issue Dec 23, 2015 · 0 comments
Open

Java1-崔雨豪1407094234 #19

cyhbrilliant opened this issue Dec 23, 2015 · 0 comments

Comments

@cyhbrilliant
Copy link

//Delete_Sheep================================================
        ArrayList<sheep> sheeplist=new ArrayList<sheep>();
        sheeplist.add(new sheep("1"));
        sheeplist.add(new sheep("2"));
        sheeplist.add(new sheep("3"));
        sheeplist.add(new sheep("4"));
        sheeplist.add(new sheep("5"));
        sheeplist.add(new sheep("6"));
        int i=0;
//  /*方法一*/:for(i=5;i>2;i--)
//          sheeplist.remove(sheeplist.get(i));
//      
//      
//  /*方法二*/:for(i=0;i<3;i++)
//          sheeplist.remove(sheeplist.get(3));
//          
//  /*方法三*/:while(sheeplist.size()!=3)
//          sheeplist.remove(sheeplist.get(3));

        for(i=0;i<3;i++)
        System.out.println(((sheep)(sheeplist.get(i))).getName());


//======================================================================
//Create_FileAuto=========================================================
public class fileTEST {
    public static void main(String[] args) {
        //建立hello world文件
        File manyfile=new File("D:\\test");
        manyfile.mkdir();
        File file = null;
        try {
            manyfile.mkdir();
            for(int i=0;i<10;i++)
            {
                file=new File(manyfile,"helloworld"+i+".txt");
                file.createNewFile();
            }
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }


        try {

            for(int i=0;i<10;i++)
            {
                OutputStream os=new FileOutputStream("D:\\test\\helloworld"+i+".txt");
                String s="andriod lab"+i;
                os.write(s.getBytes());

            }
        } 
        catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();

            }
        catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();

        }




        try {
            InputStream is=new FileInputStream("D:\\test\\helloworld"+0+".txt");
            byte[] read=new byte[1024];
            is.read(read);
            System.out.println();

        } catch (Exception e) {
            // TODO: handle exception
        }       


    }

}
//============================================================
//Threads=====================================================
public class cyh {
    public static void main(String[] args) {
        threadx thread1=new threadx();
        threadx thread2=new threadx();
        thread1.start();
        thread2.start();

        thready thread3=new thready();
        thready thread4=new thready();
        Thread thread5=new Thread(thread3);
        Thread thread6=new Thread(thread4);
        thread5.start();
        thread6.start();

    }

}


class threadx extends Thread{
    public void run(){
        System.out.println("openThread");
    }
    static int a=0;


}

class s{

}
class thready extends s implements Runnable{
    public void run() {
        System.out.println("openRunnable");

    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant