JavaµÄdz¿½±´ºÍÉ±´(1)
JavaµÄ¿½±´·ÖΪÉ±´ºÍdz¿½±´
dz¿½±´£º°ÑÒ»¸ö¶ÔÏóÖÐËùÓеķÇstatic³ÉÔ±±äÁ¿(°üÀ¨¶ÔÆäËü¶ÔÏóµÄÒýÓã¬javaÖеÄÒýÓÃÏ൱ÓÚC/C++ÖеÄÖ¸Õë±äÁ¿)¶¼¿½±´Ò»±é£¬¶ø²»¿½±´ÒýÓÃËùÖ¸ÏòµÄ¶ÔÏó
É±´£º°ÑÒ»¸ö¶ÔÏóÖÐËùÓеķÇstatic³ÉÔ±±äÁ¿(°üÀ¨¶ÔÆäËü¶ÔÏóµÄÒýÓÃ)¶¼¿½±´Ò»±é£¬ÒýÓÃËùÖ¸ÏòµÄ¶ÔÏóÒ²¿½±´Ò»·Ý
ÕâƪÎÄÕÂÏȽ²Êödz¿½±´£¬É±´ÏÂƪÎÄÕ½²Êö
Ò»¸öÀàµÄ¶ÔÏóÈç¹ûÏëÒª¾ßÓп½±´µÄ¹¦ÄÜ£¬±ÈÈç·ûºÅÈçÏÂÌõ¼þ£º
1.±ØÐëʵÏÖCloneable½Ó¿Ú(Õâ¸ö½Ó¿ÚÖÐûÓж¨Òå·½·¨£¬½Ð×ö±ê¼Ç½Ó¿Ú)
2.ÖØдObjectÀàµÄclone()·½·¨£¬¸Ã·½·¨ÊµÏÖµÄÊÇdz¿½±´
3.ÔÚ¸ÃÀàµÄclone()·½·¨ÖеĵÚÒ»¾ä£¬±ÈÈçµ÷ÓÃsuper.clone()À´µ÷ÓÃObjectµÄclone()·½·¨À´ÊµÏÖ¿½±´
ÒÔÏÂÊÇÒ»¸ödz¿½±´µÄÀý×Ó£º
package com.test;
public class CloneTest
{
public static void main(String[] args)
{
Student s1 = new Student();
s1.setAge(20);
s1.setName("wudi");
School school = new School();
school.setName("Peiyang University");
school.setBornYear(1895);
s1.setSchool(school);
System.out
.println("s1:" + s1.getName() + " " + s1.getAge() + " "
+ s1.getSchool().getName() + " "
+ s1.getSchool().getBornYear());
try
{
//¿½±´Ò»¸öѧÉú
Student s2 = (Student)s1.clone();
s2.setAge(21);
s2.setName("WUDI");
System.out
.println("s2:" + s2.getName() + " " + s2.getAge() + " "
+ s2.getSchool().getName() + " "
+ s2.getSchool().getBornYear());
System.out.println("after s2 changing some property:");
//ͨ¹ýѧÉús2¸Ä±äÁËËûËùÔÚѧУµÄÃû³ÆºÍ³ÉÁ¢Ê±¼ä
s2.getSchool().setName("Tianjin University");
s2.getSchool().setBornYear(1951);
System.out
.println("s1:" + s1.getName() + " " + s1.getAge() + " "
+ s1.getSchool().getName() + " "
+ s1.getSchool().getBornYear());
System.out
.println("s2:" + s2.getName() + " " + s2.getAge() + " "
Ïà¹ØÎĵµ£º
JAVA_HOME = F:\java\jdk £¨jdk°²×°Â·¾¶£©
PATH = .;%JAVA_HOME%/bin
CLASSPTAH = .;%JAVA_HOME%/lib
¼ìÑéÊÇ·ñÅäÖóɹ¦£º
¿ØÖÆ̨cmd
ÊäÈëjava³öÏÖÅäÖÃÐÅϢ˵Ã÷ÅäÖóɹ¦¡£ ......
ʹÓÃjava + oracle²åÈëclobÀàÐ͵ÄÊý¾Ý£¬ÐèÒªÓÃÒÔϵIJ½Ö裺
1¡¢½«Êý¾Ý²åÈëÊý¾Ý¿â£¬¶ÔÓÚclob×ֶΣ¬Ê¹ÆäΪ¿ÕclobÊý¾Ý¡£ÀýÈ磺insert into test values(1,empty_clob())";
2¡¢´ÓÊý¾Ý¿âÖÐÈ¡³ö²åÈëµÄclob×ֶΣ¬²¢½«Æ丳ֵ¸øoracle.sql.clobÀàÐ͵ıäÁ¿¡£ÀýÈç
String sqll="select content from test where id=1 for upda ......
Ö÷ÒªÊǾٸöÀý×Ó˵Ã÷Ò»ÏÂʲôÓÃthrows£¬Ê²Ã´Ê±ºòÓÃtry-catch¡£
import java.io.BufferedReader;
import java.io.File;
import java.io.FileFilter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
public class Test {
public static void main(String[] ......
1. Õ»(stack)Óë¶Ñ(heap)¶¼ÊÇJavaÓÃÀ´ÔÚRamÖдæ·ÅÊý¾ÝµÄµØ·½¡£ÓëC++²»Í¬£¬Java×Ô¶¯¹ÜÀíÕ»ºÍ¶Ñ£¬³ÌÐòÔ±²»ÄÜÖ±½ÓµØÉèÖÃÕ»»ò¶Ñ¡£
¡¡¡¡2. Õ»µÄÓÅÊÆÊÇ£¬´æÈ¡ËٶȱȶÑÒª¿ì£¬½ö´ÎÓÚÖ±½ÓλÓÚCPUÖеļĴæÆ÷¡£µ«È±µãÊÇ£¬´æÔÚÕ»ÖеÄÊý¾Ý´óСÓëÉú´æÆÚ±ØÐëÊÇÈ·¶¨µÄ£¬È±·¦Áé»îÐÔ¡£ÁíÍ⣬ջÊý¾Ý¿ÉÒÔ¹ ......
1.»ù±¾¸ÅÄîµÄÀí½â
¾ø¶Ô·¾¶£º¾ø¶Ô·¾¶¾ÍÊÇÄãµÄÖ÷Ò³ÉϵÄÎļþ»òĿ¼ÔÚÓ²ÅÌÉÏÕæÕýµÄ·¾¶£¬(URLºÍÎïÀí·¾¶)ÀýÈ磺
C:xyz est.txt ´ú±íÁËtest.txtÎļþµÄ¾ø¶Ô·¾¶¡£http://www.sun.com/index.htmÒ²´ú±íÁËÒ»¸öURL¾ø¶Ô·¾¶¡£
Ïà¶Ô·¾¶£ºÏà¶ÔÓëij¸ö»ù׼Ŀ¼µÄ·¾¶¡£°üº¬WebµÄÏà¶Ô·¾¶£¨HTMLÖеÄÏà¶ÔĿ¼£©£¬ÀýÈ磺ÔÚ
Ser ......