Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

JAVAÐòÁл¯µÄÁ½ÖÖ·½Ê½¡¾×ªÌù¡¿

JAVAÐòÁл¯µÄÁ½ÖÖ·½Ê½
//´ó¼Ò¶¼ÖªµÀSerializableÊÇÒ»¸ömark interface,¸æËßJVMÕâ¸ö¶ÔÏó¿ÉÒÔ±»×ª»»³É¶þ½øÖÆÁ÷À´´«Êä.
//Serializable ÔÚÎÒÃÇʵÏÖÕâ¸ö½Ó¿ÚµÄʱºò,ÎÒÃÇ¿ÉÒÔʹÓÃ4¸ö˽Óз½·¨À´¿ØÖÆÐòÁл¯µÄ¹ý³Ì:
//ÎÒÃÇÀ´¿´Ò»¸öÀý×Ó:
public class FooImpl implements java.io.Serializable
{
private String message;
public String getFoo()
{
return message;
}
public void setMessage( String message )
{
this.message = message;
}
private void writeObject( java.io.ObjectOutputStream out ) throws IOException
{
System.out.println( "writeObject invoked" );
out.writeObject( this.message == null ? "hohohahaha" : this.message );
}
private void readObject( java.io.ObjectInputStream in ) throws IOException, ClassNotFoundException
{
System.out.println( "readObject invoked" );
this.message = (String) in.readObject();
}
private Object writeReplace() throws ObjectStreamException
{
System.out.println( "writeReplace invoked" );
return this;
}
private Object readResolve() throws ObjectStreamException
{
System.out.println( "readResolve invoked" );
return this;
}
public Object serialize() throws IOException, ClassNotFoundException
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream( baos );
oos.writeObject( this );
ByteArrayInputStream bais = new ByteArrayInputStream( baos.toByteArray() );
ObjectInputStream ois = new ObjectInputStream( bais );
return ois.readObject();
}
public static void main(String[] args) throws IOException, ClassNotFoundException
{
FooImpl fooimpl = new FooImpl();
fooimpl.se


Ïà¹ØÎĵµ£º

JAVA ÈÕÆÚ²Ù×÷

ÓÐЩʱºò,ÎÒÃÇÏëÔÚµ±Ç°µÄÈÕÆÚÉϼӼ¸Ìì¡¢¼¸¸öÔ£¬»ò¼¸Ä꣬ʹÓÃjava.util.Date£¬È´×ÜÒ²ÕÒ²»µ½ºÏÊʵķ½·¨£¬ÎÞÄÎ֮ϣ¬ÇëÒ»¸ö¸ßÈ˰ïæ£¬ÀÏÁõ¸øÁËÒ»¾ä»°£ºÊ¹ÓÃCanlender¡£Ö®ºó£¬ÎÒ¾ÍʹÓÃCalender£¬Ò»Ó㬻¹ÕæºÃÓ㬾Íд³öÀ´£¬ºÍ´ó¼Ò¹²Í¬·ÖÏí£º
²   ÎÒµÄÐèÇó
ÎÒÔÚ×÷Ò»¸öµ÷²éÎÊ¾í£¬ÏëÉ趨ÎʾíµÄÓÐЧÌìÊý£ºÔÚ·¢²¼Ö ......

ÈçºÎʹÓÃJavaÖеÄDateºÍCalendarÀà

Java ÓïÑÔµÄCalendar(ÈÕÀú),Date(ÈÕÆÚ), ºÍDateFormat(ÈÕÆÚ¸ñʽ)×é³ÉÁËJava±ê×¼µÄÒ»¸ö»ù±¾µ«ÊǷdz£ÖØÒªµÄ²¿·Ö. ÈÕÆÚÊÇÉÌÒµÂß¼­¼ÆËãÒ»¸ö¹Ø¼üµÄ²¿·Ö. ËùÓеĿª·¢Õß¶¼Ó¦¸ÃÄܹ»¼ÆËãδÀ´µÄÈÕÆÚ, ¶¨ÖÆÈÕÆÚµÄÏÔʾ¸ñʽ, ²¢½«Îı¾Êý¾Ý½âÎö³ÉÈÕÆÚ¶ÔÏó. ÎÒÃÇдÁËÁ½ÆªÎÄÕÂ, ÕâÊǵÚһƪ, Î ......

java×°ÏäÓë²ðÏä

/**
* ==ºÅÊDZȽÏÁ½¸ö»ù±¾ÀàÐÍÊÇ·ñÏàµÈ,»òÕ߱ȽÏÁ½¸ö¶ÔÏóÒýÓÃÊÇ·ñÏàͬ
*/
public class T {

public static void main(String[] args) {
Integer i1 = 128;
Integer i2 = 128;
int i3 = 128;
int i4 = 128;
Integer i5 = 127;
Integer i6 = 127; ......

JAVA¿ª·¢Õß×ȥµÄ20¸öÓ¢ÎÄÍøÕ¾

1.[http://www.javaalmanac.com] – Java¿ª·¢ÕßÄê¼øÒ»ÊéµÄÔÚÏß°æ±¾. ÒªÏë¸ßËٲ鵽ijÖÖJava¼¼ÄܵÄÓ÷¨¼°Ê¾·¶´úÂë, ÕâÊÇÒ»¸ö²»´íµÄÈ¥´¦.
2.[http://www.onjava.com] – O’ReillyµÄJavaÍøÕ¾. ÿÖܶ¼ÓÐиå×Ó.
3.[http://java.sun.com] – ¹Ù·½µÄJava¿ª·¢ÕßÍøÕ¾ – ÿÖܶ¼ÓÐиå¼þ·¢±í.
4.[htt ......

java±à³ÌÎļþ¿½±´

import java.io.FileInputStream;
public class FileCopy{
      public static void main(String[] args){
                  try{
         &nb ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ