????1??Java?????д????????5????????

???????Jvm????????????????????????????£???Java?У???????5??????????????

????1??????????new???ù?????????Java????eg??String str = new String("hello");

????2?????Class?????newInstance()???????ù?????????Java????eg??Class.forName("com.mysql.jdbc.Driver").newInstance();

????3?????Java??????л??????IO???л??Java????eg??

package test;
 
 import java.io.Serializable;
 
 public class Person implements Serializable {
 
     static final long serialVersionUID = 1L;
 
     String name; // ????
 
     public Person() {}
   
     public Person(String name) {
         super();
         this.name = name;
     }
 }

package test;
 
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 
 public class ObjectIo {
     public static void main(String[] args) throws Exception {
         Person p = new Person("С??");
         FileOutputStream fos = new FileOutputStream("d:/objectIoTest.dat");
         ObjectOutputStream oos = new ObjectOutputStream(fos);
         oos.writeObject(p);
         oos.flush();
         oos.close();    //??????ж?????????漸?????Java??????л??????IO???л??Java?????????
       
         //????????????Java??????л??????IO???л??Java????
         FileInputStream fis = new FileInputStream("d:/objectIoTest.dat");
         ObjectInputStream ois = new ObjectInputStream(fis);
         Person person = (Person) ois.readObject();
         System.out.println("??????? ?? " + person.name);
     }
 }

???????н????

????4?????Java????????clone()????????????μ?Java????eg??

package test;
 
 /**
  * ???????Cloneable??????????дclone()????
  * @ClassName: Base
  * @author С??
  * @date 2013-3-28
  */
 public class Base implements Cloneable{
     int i = 20;
   
     @Override
     protected Object clone() throws CloneNotSupportedException {
         return super.clone();
     }
 }

package test;
 
 public class CloneTest {
     public static void main(String[] args) throws Exception {
         Base b = new Base();
         Base c = (Base) b.clone();
         System.out.println("b??c??????????? " + (c == b));
     }
 }