java clone ½âÎö
ת×Ô£ºhttp://ttitfly.javaeye.com/blog/155422
1.javaÀïµÄclone·ÖΪ£º
A:dz¸´ÖÆ£¨Ç³¿Ë¡£©: dz¸´Öƽö½ö¸´ÖÆËù¿¼ÂǵĶÔÏ󣬶ø²»¸´ÖÆËüËùÒýÓõĶÔÏó¡£
b:ÉÖÆ£¨Éî¿Ë¡£©£ºÉÖÆ°ÑÒª¸´ÖƵĶÔÏóËùÒýÓõĶÔÏ󶼸´ÖÆÁËÒ»±é¡£
JavaÖжÔÏóµÄ¿Ë¡,ΪÁË»ñÈ¡¶ÔÏóµÄÒ»·Ý¿½±´£¬ÎÒÃÇ¿ÉÒÔÀûÓÃObjectÀàµÄclone()·½·¨¡£±ØÐëÒª×ñÑÏÂÃæÈýµã
1.ÔÚÅÉÉúÀàÖи²¸Ç»ùÀàµÄclone()·½·¨£¬²¢ÉùÃ÷Ϊpublic¡¾ObjectÀàÖеÄclone()·½·¨ÎªprotectedµÄ¡¿¡£
2.ÔÚÅÉÉúÀàµÄclone()·½·¨ÖУ¬µ÷ÓÃsuper.clone()¡£
3.ÔÚÅÉÉúÀàÖÐʵÏÖCloneable½Ó¿Ú¡£
ObjectÀàÀïµÄclone·½·¨ÊÇdz¸´ÖÆ£¨Ç³¿Ë¡£©
1.dz¸´ÖÆ£¨Ç³¿Ë¡£©µÄÀý×ÓÈçÏ£º
package com.test;
//dz¸´ÖÆ£¨Ç³¿Ë¡£©: dz¸´Öƽö½ö¸´ÖÆËù¿¼ÂǵĶÔÏ󣬶ø²»¸´ÖÆËüËùÒýÓõĶÔÏó¡£
//ÉÖÆ£¨Éî¿Ë¡£©£ºÉÖÆ°ÑÒª¸´ÖƵĶÔÏóËùÒýÓõĶÔÏ󶼸´ÖÆÁËÒ»±é¡£
//
//JavaÖжÔÏóµÄ¿Ë¡,ΪÁË»ñÈ¡¶ÔÏóµÄÒ»·Ý¿½±´£¬ÎÒÃÇ¿ÉÒÔÀûÓÃObjectÀàµÄclone()·½·¨¡£±ØÐëÒª×ñÑÏÂÃæÈýµã
//1.ÔÚÅÉÉúÀàÖи²¸Ç»ùÀàµÄclone()·½·¨£¬²¢ÉùÃ÷Ϊpublic¡¾ObjectÀàÖеÄclone()·½·¨ÎªprotectedµÄ¡¿¡£
//2.ÔÚÅÉÉúÀàµÄclone()·½·¨ÖУ¬µ÷ÓÃsuper.clone()¡£
//3.ÔÚÅÉÉúÀàÖÐʵÏÖCloneable½Ó¿Ú¡£
//[color=red]ObjectÀàÀïµÄclone·½·¨ÊÇdz¸´ÖÆ£¨Ç³¿Ë¡£©[/color]public class CloneTest {
public static void main(String[] args) throws Exception{
//teacher¶ÔÏ󽫱»clone³öÀ´µÄStudent¶ÔÏó¹²Ïí.
Teacher teacher = new Teacher();
teacher.setAge(40);
teacher.setName("Teacher zhang");
Student student1 = new Student();
student1.setAge(20);
student1.setName("zhangsan");
student1.setTeacher(teacher);
//¸´ÖƳöÀ´Ò»¸ö¶ÔÏóstudent2
Student student2 = (Student)student1.clone();
System.out.println(student2.getAge());
System.out.println(student2.getName());
System.out.println("~~~~~~~~~~~~~~~~~~~~~~");
System.out.println(student1.getTeacher().getAge());
System.out.println(student1.getTeacher().getName());
//ÐÞ¸Ästudent2µÄÒýÓöÔÏó
student2.getTeacher().setAge(50);
student2.getTeacher().setName("Teacher Li");
System.out.println("~~~~~~~~~~~~~~~~~~~~~~");
System.out.println(student1.getTeacher().getAge());
S
Ïà¹ØÎĵµ£º
Ŀ¼
ÕªÒª ……………………………………………………………………2
ÎÄÏ××ÛÊö ……………………&h ......
Ò»£®POI¼ò½é
Jakarta POI ÊÇapacheµÄ×ÓÏîÄ¿£¬Ä¿±êÊÇ´¦Àíole2¶ÔÏó¡£ËüÌṩÁËÒ»×é²Ù×ÝWindowsÎĵµµÄJava API
Ä¿Ç°±È½Ï³ÉÊìµÄÊÇHSSF½Ó¿Ú£¬´¦ÀíMS Excel£¨97-2002£©¶ÔÏó¡£Ëü²»ÏóÎÒÃǽö½öÊÇÓÃcsvÉú³ÉµÄûÓиñʽµÄ¿ÉÒÔÓÉExcelת»»µÄ¶«Î÷£¬¶øÊÇÕæÕýµÄExcel¶ÔÏó£¬Äã¿ÉÒÔ¿ØÖÆһЩÊôÐÔÈçsheet,cellµÈµÈ¡£
¶þ£®HSSF¸Å¿ö
......
ÔÚÍøÉÏ¿´µ½ºÜ¶àÈ˶¼ÔÚΪDelphiÊÇ·ñÖ§³ÖC++/JavaÖеľ²Ì¬±äÁ¿¼°¾²Ì¬·½·¨µÄ¹¦ÄܶøÀ§ÈÅ,ÆäʵÕâÔÚDelphiÖÐÊǺܼòµ¥µÄ.
¾²Ì¬·½·¨¾ÍÊÇʹÓÃClass Function. ¾²Ì¬±äÁ¿ÔòʹÓõ¥Ôª¾Ö²¿±äÁ¿À´ÊµÏÖ. ´úÂëÈçÏÂ:
//=========================================
// StaticVarTestU - ¶¨ÒåÁË¿ÉÒÔ¼ÆÊýµÄÀ࣬ͨ¹ýÀà·½·¨¼´¿É·ÃÎÊ´ËÀàµÄ¶ÔÏóÊý ......
Õâ±¾ÊéÏêϸ½²½âÁËģʽÀíÂÛµÄÓÉÀ´£¨ºÜ¶àÈË¿ÉÄܲ»ÖªµÀģʽÀíÂÛÓëÖйúµÀ¼Ò˼ÏëµÄÔ¨Ô´£©£¬ÃæÏò¶ÔÏóµÄÈí¼þÉè¼ÆÔÔò£¬Ò»Ö±½²µ½¶þÊ®¼¸¸öÉè¼Æģʽ£¬ÒÔ¼°ÕâЩģʽÔÚJavaÓïÑÔÖеÄʵÏֵȵȡ£ÊéÖиø³öÁË´óÁ¿À´×Ô»ª¶û½ÖϵͳµÄÕæʵÏîÄ¿µÄÀý×Ó£¬ÓÃÀ´½²½âÉè¼ÆģʽÔÚϵͳÉè¼ÆÖеÄÓ¦ÓᣠÕâ±¾Êé´¦ÓÚÀíÂÛºÍʵ¼ùÖ®¼ä£¬ÊÇÒ»±¾¶¨Î»¶ÀÌØ¡¢·ç¸ñ¶ÀÌص ......
ÔÚ±¾ÎÄͨ¹ýÌṩʹJava Ó¦ÓóÌÐò¿ÉÒÔʹÓà USB É豸µÄ API ¶øʹÕâ¸ö¹ý³Ì±äµÃ¸üÈÝÒ×.
Java ƽ̨һֱ¶¼ÒÔÆäƽ̨ÎÞ¹ØÐÔ×ÔºÀ¡£ËäÈ»ÕâÖÖÎÞ¹ØÐÔÓÐÐí¶àºÃ´¦£¬µ«ÊÇËüҲʹµÃ±àдÓëÓ²¼þ½»»¥µÄ Java Ó¦ÓóÌÐòµÄ¹ý³Ì±äµÃÏ൱¸´ÔÓ¡£ÔÚ±¾ÎÄÖУ¬Ñо¿¿Æѧ¼Ò½¯ÇåÒ°ÌÖÂÛÁËÁ½¸öÏîÄ¿£¬ËüÃÇͨ¹ýÌṩʹJava Ó¦ÓóÌÐò¿ÉÒÔʹÓà USB É豸µÄ API ¶øʹÕâ ......