Java±à³ÌÄÇЩʶù2_·½·¨
Java±à³ÌÄÇЩʶù52—·½·¨ÉùÃ÷
µÚÆßÕÂ ·½·¨
·½·¨µÄÀ´Ô´
·½·¨µÄ¸ÅÄîÀ´Ô´ÓÚÊýѧÉϵĺ¯Êý£¬ÔÚÊýѧÖУ¬µ±Êý¾Ý¾ßÓÐÒ»¶¨µÄ¹æÂÉʱ£¬¾ÍÊÇÓÃÒ»¸öº¯ÊýÀ´´úÂë¸ÃÊý×ֵĹæÂÉ£¬ÀýÈçf£¨n£©=nÔò´ú±í1¡¢2¡¢3¡¢……ÕâÑùµÄÒ»¸öÊýÁС£ÔÚÊýѧÉÏnÊDzÎÊý£¬¶ÔÓÚÈ·¶¨µÄnÖµÖ»ÓÐÒ»¸öf£¨n£©µÄÖµºÍËü¶ÔÓ¦
·½·¨ÊÇÒ»×éΪÁËʵÏÖÌض¨¹¦ÄܵĴúÂë¿éµÄ¼¯ºÏ¡£·½·¨ÔÚÓï·¨ÉϵŦÄÜÖ÷ÒªÓÐÒÔÏÂÁ½¸ö£º
l½á¹¹»¯´úÂë
½«´úÂë°´ÕÕ¹¦ÄܽøÐÐ×éÖ¯£¬Ê¹´úÂëµÄ½á¹¹±È½ÏÇåÎú£¬ÈÝÒ×ÔĶÁºÍÐ޸ģ¬Ò²¾ÍÊdzÌÐòµÄ¿Éά»¤ÐÔÇ¿¡£
l¼õÉÙ´úÂëÖظ´
Ò»¸ö¹Ì¶¨µÄ¹¦ÄÜ£¬¿ÉÄÜ»áÔÚ³ÌÐòÖжà´ÎʹÓã¬ÔÚʹÓÃʱֻÐèÒªµ÷ÓÃдºÃµÄ·½·¨£¬¶ø²»ÓÃÖظ´Êéд¶ÔÓ¦µÄ¹¦ÄÜ´úÂë¡£
·½·¨ÔÚÊéдʱÐèҪעÒâÒÔÏÂÁ½µã£º
lÂß¼ÑϽ÷
·½·¨ÊµÏÖµÄÒ»¸öÍêÕûµÄ¹¦ÄÜ£¬ËùÒÔÔÚÊéдʱҪ¿¼Âǵ½¸÷ÖÖ¿ÉÄܵÄÇé¿ö£¬²¢¶ÔÿÖÖÇé¿ö×ö³öÇ¡µ±µÄ´¦Àí¡£
lͨÓÃÐÔÇ¿
·½·¨ÊµÏÖµÄÊÇÒ»ÖÖ¹¦ÄÜ£¬ÔÚʵ¼ÊʵÏÖʱ£¬¿ÉÒÔ¸ù¾ÝÐèÒª£¬Ê¹·½·¨¾ß±¸Ò»¶¨µÄͨÓÃÐÔ£¬³ý·Ç±ØÒª£¬·ñÔò²»ÒªÐ´×¨Óõķ½·¨¡£
ÔÚJavaÓïÑÔÖУ¬Ç¡µ±µÄʹÓ÷½·¨£¬½«Ê¹³ÌÐò¸ü¼ÓÓÅÑÅ£¬±ãÓÚÔĶÁºÍʹÓá£ÏÂÃæ¾ÍÀ´½éÉÜ·½·¨ÉùÃ÷µÄÓï·¨¸ñʽ¡£
·½·¨ÉùÃ÷£¬¾ÍÊÇÉùÃ÷Ò»ÖÖÐµĹ¦ÄÜ£¬»òÕß˵´´ÔìÒ»ÖÖÐµĹ¦ÄÜ¡£ÀýÈçÒÔÏÂÊÇÒ»¸öÇóintÊý¾Ý¾ø¶ÔÖµµÄ·½·¨ÉùÃ÷´úÂ룺
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ publicintabs(int n){
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ if(n > 0){
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ return n;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ }else{
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ return –n;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ }
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ }
ÕâÀï¾ÍʵÏÖÁËÇóintÖµ¾ø¶ÔÖµµÄ¹¦ÄÜ£¬ÎªÁËʹ¸Ã¹¦ÄÜͨÓã¬Ê¹ÓÃÒ»¸ö²ÎÊýn´ú±íÐèÒªÇó¾ø¶ÔÖµµÄÊýÖµ£¬ÔÚ·½·¨ÄÚ²¿Ê¹ÓÃÇó¾ø¶ÔÖµµÄÂß¼£ºÕýÊýµÄ¾ø¶ÔÖµÊÇ×ÔÉí£¬¸ºÊýµÄ¾ø¶ÔÖµÊÇÏà·´Êý£¬Ê¹ÓÃreturnÓï¾ä½«·½·¨ÔËËãµÄ½á¹û·µ»Ø¡£
¾ßÌå·½·¨ÉùÃ÷µÄÓï·¨¸ñʽÈçÏ£º
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ ·ÃÎÊ¿ØÖÆ·û[ÐÞÊηû]·µ»ØÖµÀàÐÍ·½·¨Ãû³Æ(²ÎÊýÁбí){
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ ·½·¨Ìå
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ }
1¡¢·ÃÎÊ¿ØÖÆ·û
·ÃÎÊ¿ØÖÆ·ûÏÞ¶¨·½·¨µÄ¿É¼û·¶Î§£¬»òÕß˵ÊÇ·½·¨±»µ÷Óõķ¶Î§¡£·½·¨µÄ·ÃÎÊ¿ØÖÆ·ûÓÐËÄÖÖ£¬°´¿É¼û·¶Î§´Ó´óµ½Ð
Ïà¹ØÎĵµ£º
×î½üÓöµ½Ò»¸öÐèÇóÒªÔÚlinuxÏÂÓÃjava µ÷ÓÃmysql¿Í»§¶ËÔ¶³ÌµÇ½mysql·þÎñÆ÷£¬´Ó¿Í»§¶Ë»úÆ÷µ¼Èëmysql½Å±¾£¬´Ómysql·þÎñÆ÷¶Ëµ¼³ö±íÖеÄÊý¾Ý¡£ÒÔÏÂÊÇÓõ½µÄÖ÷Òª·½·¨£º
Java ´úÂë
/**
* µ¼ÈëÊý¾Ý
* @param ½Å±¾µÄµØÖ·ºÍÃû³Æ
* @return ÊÇ·ñ³ ......
import java.awt.*;
import javax.swing.*;
import java.util.Date;
import java.awt.*;
class Time extends JFrame implements Runnable{//ʵÏÖ½Ó¿Ú
Thread clockThread;
JLabel jLabel=new JLabel();
public Time()
{
Container con=this.getContentPane() ......
1¡¢FACTORY£¨¹¤³§Ä£Ê½£©
2¡¢BUILDER£¨½¨Ôìģʽ£©
3¡¢FACTORY METHOD£¨¹¤³§·½·¨Ä£Ê½£©
4¡¢PROTOTYPE£¨ÔʼģÐÍģʽ£©
5¡¢SINGLETON£¨µ¥Àýģʽ£©
6¡¢ADAPTER£¨ÊÊÅäÆ÷ģʽ£©
7¡¢BRIDGE£¨ÇÅÁºÄ£Ê½£©
8¡¢COMPOSITE£¨ºÏ³Éģʽ£©
9¡¢DECORATOR£¨×°ÊÎģʽ£©
10¡¢FACADE£¨ÃÅÃæģʽ£©
11¡¢FLYWEIGHT£¨ÏíԪģʽ£© ......
Ç°Ò»ÕóÔÚ¹«Ë¾ÀïʹÓà jconsle ʱһÇÐÕý³££¬È»¶øÔÚ¼ÒÖеĻúÆ÷ÉÏÈ´³öÏÖÁ˱êÌâËùʾµÄÎÊÌ⣺
jconsole ºÍ jps ÎÞ·¨ÏÔʾ±¾µØ Java ½ø³ÌÁÐ±í¡£
µ±Ê±Ö±½ÓÀûÓà -Dcom.sun.management.jmxremote.port=port Æô¶¯Ä¿±ê java ½ø³Ì£¬²¢ÔÚ jconsole ÖÐͨ¹ý localhost:port ·½Ê½³É¹¦Á¬½ÓÉÏÄ¿±ê java ½ø³Ì¡£ÓÐÁËÕâ¸ö work around Ö®ºó£¬¶ÔÕ ......
Ò»¡¢ÔËÐÐclassÎļþ
Ö´Ðдømain·½·¨µÄclassÎļþ£¬ÃüÁîÐÐΪ£º
java <CLASSÎļþÃû>
×¢Ò⣺CLASSÎļþÃû²»Òª´øÎļþºó׺.class
ÀýÈ磺
java Test
Èç¹ûÖ´ÐеÄclassÎļþÊÇ´ø°üµÄ£¬¼´ÔÚÀàÎļþÖÐʹÓÃÁË£º
package <°üÃû>
ÄÇÓ¦¸ÃÔÚ°üµÄ»ù·¾¶ÏÂÖ´ÐУ¬ÃüÁîÐÐΪ£º
java <°üÃû>.CLASSÎļþ ......