½ÌÄãÉîÈëÁ˽âJavaÖнӿڵÄʹÓÃ
±¾ÆªÎÄÕÂÀ´Ô´ÓÚ£º¿ª·¢Ñ§Ôº http://edu.codepub.com ÔÎÄÁ´½Ó£ºhttp://edu.codepub.com/2010/0221/20469.php
½Ó¿ÚÉêÃ÷±ØÐëÓÐinterface¹Ø¼ü×ֺͽӿڵÄÃû×Ö£¬publicÖ¸Ã÷ÈÎÒâÀà¾ù¿ÉÒÔʹÓÃÕâ¸ö½Ó¿Ú£¬Ä¬ÈÏÇé¿öÏ£¬Ö»ÓÐÓë¸Ã½Ó¿Ú¶¨ÒåÔÚͬһ¸ö°üÖеÄÀà²Å¿ÉÒÔ·ÃÎÊÕâ¸ö½Ó¿Ú¡£extends ÓëÀàÉêÃ÷ÖеÄextends »ù±¾Ïàͬ£¬²»Í¬µÄÊÇÒ»¸ö½Ó¿Ú¿ÉÒÔÓжà¸ö¸¸½Ó¿Ú£¬ÓöººÅ¸ô¿ª¡£¶øÒ»¸öÀàÖ»ÄÜÓÐÒ»¸ö¸¸Àà¡£×ӽӿڼ̳нӿÚÖÐËùÓеij£Á¿ºÍ·½·¨¡£ÔÚÀàµÄÉêÃ÷ÖÐÓÃimplementsÀ´±íʾһ¸öÀàʵÏÖij¸ö½Ó¿Ú£¬ÔÚÀàÌåÖпÉÒÔʹÓýӿÚÖж¨ÒåµÄ³£Á¿£¬¶øÇÒ±ØÐëʵÏÖ½Ó¿ÚÖж¨ÒåµÄËùÓз½·¨£¨¿ÉÒÔÊǿյÄʵÏÖµ«Ò»¶¨ÒªÊµÏÖ£©£¬·ñÔò¸ÃÀà¾ÍÊÇÒ»¸ö³éÏóÀà¡£Ò»¸öÀà¿ÉÒÔʵÏÖ¶à¸ö½Ó¿Ú¡£½Ó¿ÚµÄ×÷Óã¬Ò»ÑÔÒÔ±ÎÖ®£¬¾ÍÊDZêÖ¾ÀàµÄÀà±ð£¨type of class£©¡£°Ñ²»Í¬ÀàÐ͵ÄÀà¹éÓÚ²»Í¬µÄ½Ó¿Ú£¬¿ÉÒÔ¸üºÃµÄ¹ÜÀíËûÃÇ¡£OOµÄ¾«Ë裬ÎÒÒÔΪ£¬ÊǶԶÔÏóµÄ³éÏó£¬×îÄÜÌåÏÖÕâÒ»µãµÄ¾ÍÊǽӿڡ£
½Ó¿Ú²»ÊÇÀ࣬ÓÈÆäÊǾø¶Ô²»ÄÜʹÓÃnew ²Ù×÷·ûʵÀý»¯½Ó¿Ú£»
Module md=new Module()//´íÎó
²»¹ý£¬ËäÈ»²»Äܹ¹Ôì½Ó¿Ú¶ÔÏ󣬵«»¹ÊÇ¿ÉÒÔÉùÃ÷½Ó¿Ú±äÁ¿¡£
Module md;
½Ó¿Ú±äÁ¿±ØÐëÖ¸ÏòÒ»¸öʵÏÖÁ˸ýӿڵÄÀàµÄ¶ÔÏó£»
x=new MotorModule();//ֻҪʵÏÖÁËModule¾Í¶ÔÁË
¿ÉÒÔÓÃinstanceofÀ´¼ìÑé¶ÔÏóÊÇ·ñʵÏÖÁËij¸ö½Ó¿Ú(Ö»ÒªËüÊôÓÚµÄÀà»òÕ߸¸ÀàʵÏÖÁËij¸ö½Ó¿Ú¶¼¿ÉÒÔ)£»
if(anObject instanceof Module){...}
½Ó¿ÚÔÚÈí¼þ·¢²¼µÄʱºòÊÇÏòÓû§¹«¿ªµÄ£¬Óû§¿ÉÒÔͨ¹ýµ÷ÓÃʵÏÖ½Ó¿ÚµÄÀàµÄ½Ó¿Ú·½·¨£¬¶øÈç¹û²»ÊµÏÖ½Ó¿ÚÓû§ÊDz»Äܵ÷Óõġ£
Ò²¾ÍÊÇÎÒÃdz£¿ÉÒÔÌýµ½µÄ·þÎñÌṩÉÌÕâÑù˵:"Èç¹ûÄãÃǵÄÀà×ñÑÒ»¸öÌØ¶¨µÄ½Ó¿Ú,ÄÇôÎÒÃǽ«Ö´ÐÐÕâЩ·þÎñ
java ½Ó¿ÚµÄʹÓþÙÀý
//ÒÔϳÌÐò˵Ã÷ ²¢²»ÑϽ÷,Ö»ÊÇΪÁË·½±ã³õѧÕß³õ²½µÄÀí½â½Ó¿ÚµÄÓ¦ÓÃ
interface Interface //½Ó¿Ú {
&nbs
Ïà¹ØÎĵµ£º
Ò».ÔÚj2seÀïÎÒÃÇ¿ÉÒÔʹÓÃMath.random()·½·¨À´²úÉúÒ»¸öËæ»úÊý£¬Õâ¸ö²úÉúµÄËæ»úÊýÊÇ0-1Ö®¼äµÄÒ»¸ödouble£¬ÎÒÃÇ¿ÉÒÔ°ÑËû³ËÒÔÒ»¶¨µÄÊý£¬±ÈÈç˵³ËÒÔ100£¬Ëû¾ÍÊǸö100ÒÔÄÚµÄËæ»ú£¬Õâ¸öÔÚj2meÖÐûÓС£
¶þ.ÔÚjava.utilÕâ¸ö°üÀïÃæÌṩÁËÒ»¸öRandomµÄÀ࣬ÎÒÃÇ¿ÉÒÔн¨Ò»¸öRandomµÄ¶ÔÏóÀ´²úÉúËæ»úÊý£¬Ëû¿ÉÒÔ²úÉúËæ»úÕûÊý¡¢Ëæ»úfloat¡¢ ......
1¡¢½«String/StringBuffer±äÁ¿µÄÖµÖÃΪnull£¬ÔòÆäËùÕ¼ÄÚ´æ»áºÜ¿ì±»»ØÊÕ¡£
2¡¢ÔËÐйý³ÌÖнöÒÀÀµÓÚÊäÈë²ÎÊýµÄ·½·¨£¬ÈçÊýѧ·½·¨£»¾²Ì¬³ÉÔ±±äÁ¿³£Îª¶¨Òå³£Êý£¬ÓÃÏÞ¶¨´Êpublic static final£»¾²Ì¬³ÉÔ±±äÁ¿¿É½ÚÊ¡ÄÚ´æ¡£
3¡¢½Ó¿Ú£ºÈôÓÐÐèÍê³É³éÏóµÄ¶¯×÷»ò¾ßÓиÅÄîÐÔµÄÊôÐÔ£¬ÔòÔÚ½Ó¿ÚÖж¨Òå¸Ã¶¯×÷»ò¸ÅÄÔÚʵÏָýӿڵÄÀàÖоßÌå» ......
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
public class CipherTest {
public static void main(String[] args) {
try {
byte[] keydata = { (byte) 0x00, (byte) 0x01, (byte) 0x02,
(byte) 0x03, (byte) 0x04, (byte) 0x05, (byte) 0x06,
......
import javax.swing.*;
import java.awt.BorderLayout;
import java.awt.Graphics;
import java.awt.event.*;
public class ThreadDemo extends JFrame {
/**
*
*/
private static final long serialVersionUID = 1L;
public ThreadDemo() {
JButton btn = new JButton("Click me");
btn.addActionL ......
ÎÒºÜϲ»¶Ñ§Ï°java£¬ÄÇÊÇÔÚÎÒÕýʽÉÏÁËÕâ¸ö¿Îºó¾Íϲ»¶ÉÏÁË£¬ÎÒ¾õµÃÎÒѧµÄÖ»ÊÇÒ»°ã£¬µ«ÊÇÎÒÏë°ÑÎÒµÄһЩ¸öÈ˾ÑéдÏÂÀ´£¬ºÇºÇ¡£¡£¡£¡£¡£
javaÊÇÃæÏò¶ÔÏóµÄ±à³ÌÓïÑÔ£¬ÎÒÒÔǰֻÊdzõ²½Ñ§Ï°¹ýc£¬Ñ§Ï°javaʱһЩ»ù±¾µÄÓï·¨Ö»ÊÇ¿´ÁË¿´£¬ÒòΪºÍcÊDz¶àµÄ£¬µ«ÊǺóÀ´²»¶ÏµØÑ§Ï°·¢ÏÖ¡£Ñ§Ï°javaÒªºÃºÃÊìϤ¸÷ÖÖ¸÷ÑùµÄÀֻ࣬Ҫ½«¸÷ÖÖÀàÊì ......