Java¶ÔÏó¿½±´
public class Person implements Serializable {
private String name;
private int age;
private GregorianCalendar birthday;
public Person(){
}
public Person(String name, int age, GregorianCalendar birthday){
this.name = name;
this.age = age;
this.birthday = birthday;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public GregorianCalendar getBirthday() {
return birthday;
}
public void setBirthday(GregorianCalendar birthday) {
this.birthday = birthday;
}
public static void main(String[] args) {
Person p = new Person("ÕÅÈý",13,new GregorianCalendar(1985,8,1));
Person p2 = null;
try{
ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(byteOut);
oos.writeObject(p);
Ïà¹ØÎĵµ£º
http://www.javaworld.com/javaworld/javaqa/2000-05/03-qa-0526-pass.html
Does Java pass by reference or pass by value?
Why can't you swap in Java?
By Tony
Sintes, JavaWorld.com, 05/26/00
Print
Email
Feedback
Resources
Discuss
(76)
Digg
Reddit
SlashDot
Stumble
......
1¡¢´´½¨ÁËÒ»¸ö¶ÔÏóºó£º
£¨1£©Ã»ÓÐÔÚÊʵ±µÄµØ·½Êͷŵô
£¨2£©ÔÚÓ¦¸ÃÊͷŵĵط½Ã»ÓÐ×öÊͷŲÙ×÷
ÀýÈ磺ÏÂÃæÒ»¶Î³ÌÐò£º
m_progressDlg = ProgressDialog.show(this, getString(R.string.market),getString(R.string.is_visiting), true);
new Thread() {
public v ......
Ḭ̈߳²È« ʲôÊÇḬ̈߳²È«(thread-safe)£¿ Ò»¸öÀ࣬Èç¹ûÄܹ»ÔÚ¶àÏ̲߳¢·¢·ÃÎʵĻ·¾³Ï£¨²»¹ÜÏ̷߳ÃÎʵÄ˳Ðò£©ÕýÈ·±íÏÖ×Ô¼ºµÄÐÐΪ£¬²¢ÇÒÎÞÐèÍⲿµ÷ÓÃÌí¼ÓÈκÎͬ²½Ö®ÀàµÄ²Ù×÷£¬Õâ¸öÀà¾ÍÊÇḬ̈߳²È«µÄ¡£
Õâ¸öÕýÈ·ÐÔ¿ÉÒÔÕâôÀí½â£¬¾ÍÊÇ˵¶àÏ̷߳ÃÎʵĽá¹û²»»á²»Í¬ÓÚµ¥Ï̵߳ķÃÎÊ¡£
Ḭ̈߳²È«µÄÀ಻ÐèÒªÍⲿµ÷ÓÃÌá¹©È ......
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
/**
* ÇóÖÊÊýºÍ£¬
* Èç:
* sum(1)=2=2
* sum(2)=2+3=5
* sum(3)=2+3+5=10
* sum(4)=2+3+5+7=17
& ......