java·ÃÎÊÐÞÊηûÏê½â
1¡¢ÀàµÄÐÞÊηû·ÖΪ£º¿É·ÃÎÊ¿ØÖÆ·ûºÍ·Ç·ÃÎÊ¿ØÖÆ·ûÁ½ÖÖ¡£
¿É·ÃÎÊ¿ØÖÆ·ûÊÇ£º¹«¹²ÀàÐÞÊηû public
·Ç·ÃÎÊ¿ØÖÆ·ûÓУº³éÏóÀàÐÞÊηû abstract £»×îÖÕÀàÐÞÊηû final
1 £©¹«¹²ÀàÐÞÊηû public £º Java ÓïÑÔÖÐÀàµÄ¿É·ÃÎÊ¿ØÖÆ·ûÖ»ÓÐÒ»¸ö£º public ¼´¹«¹²µÄ¡£Ã¿¸ö Java ³ÌÐòµÄÖ÷À඼±ØÐëÊÇ public Àà×÷Ϊ¹«¹²¹¤¾ß¹©ÆäËüÀàºÍ³ÌÐòʹÓõÄÓ¦¶¨ÒåΪ public Àà¡£
2 £©³éÏóÀàÐÞÊηû abstract £º·²ÊÇÓà abstract ÐÞÊηûÐÞÊεÄÀ࣬±»³ÆΪ³éÏóÀà¡£Ëùν³éÏóÀàÊÇÖ¸ÕâÖÖÀàûÓоßÌå¶ÔÏóµÄÒ»ÖÖ¸ÅÄîÀà¡£ÕâÑùµÄÀà¾ÍÊÇ Java ÓïÑ﵀ abstract Àà¡£
3 £© ×îÖÕÀàÐÞÊηû final £ºµ±Ò»¸öÀ಻¿ÉÄÜÓÐ×ÓÀàʱ¿ÉÓÃÐÞÊηû final °ÑËü˵Ã÷Ϊ×îÖÕÀà¡£±»¶¨ÒåΪ final µÄÀàͨ³£ÊÇһЩÓй̶¨×÷Óá¢ÓÃÀ´Íê³ÉijÖÖ±ê×¼¹¦ÄܵÄÀà¡£
4 £©Ààȱʡ·ÃÎÊ¿ØÖÆ·û£ºÈç¹ûÒ»¸öÀàûÓзÃÎÊ¿ØÖÆ·û£¬ËµÃ÷Ëü¾ßÓÐȱʡµÄ·ÃÎÊ¿ØÖÆ·ûÌØÐÔ¡£´Ëʱ£¬Õâ¸öÀàÖ»Äܱ»Í¬Ò»¸ö°üÖеÄÀà·ÃÎÊ»òÒýÓá£ÕâÒ»·ÃÎÊÌØÐÔÓÖ³ÆΪ°ü·ÃÎÊÐÔ¡£
2 £®ÓòµÄ¿ØÖÆÐÞÊηûÒ²·ÖΪ£º¿É·ÃÎÊ¿ØÖÆ·ûºÍ·Ç·ÃÎÊ¿ØÖÆ·ûÁ½Àà¡£
¿É·ÃÎÊ¿ØÖÆ·ûÓÐ 4 ÖÖ£º¹«¹²·ÃÎÊ¿ØÖÆ·û£º public £»Ë½ÓзÃÎÊ¿ØÖÆ·û£º private £»±£»¤·ÃÎÊ¿ØÖÆ·û£º protected £»Ë½Óб£»¤·ÃÎÊ¿ØÖÆ·û£º private protected
·Ç·ÃÎÊ¿ØÖÆ·ûÓÐ 4 ÖÖ£º¾²Ì¬ÓòÐÞÊηû£º static £»×îÖÕÓòÐÞÊηû£º final £»Ò×ʧ ( ¹²Ïí ) ÓòÐÞÊηû£º volatile £»ÔÝʱÐÔÓòÐÞÊηû£º transient
1 £©¹«¹²·ÃÎÊ¿ØÖÆ·û public £ºÓà public ÐÞÊεÄÓò³ÆΪ¹«¹²Óò¡£Èç¹û¹«¹²ÓòÊôÓÚÒ»¸ö¹«¹²À࣬Ôò¿ÉÒÔ±»ËùÓÐÆäËüÀàËùÒýÓá£ÓÉÓÚ public ÐÞÊηû»á½µµÍÔËÐеݲȫÐÔºÍÊý¾ÝµÄ·â×°ÐÔ£¬ËùÒÔÒ»°ãÓ¦¼õÉÙ public ÓòµÄʹÓá£
2 £©Ë½ÓзÃÎÊ¿ØÖÆ·û private £º Óà private ÐÞÊεijÉÔ±±äÁ¿ ( Óò ) Ö»Äܱ»¸ÃÀà×ÔÉíËù·ÃÎÊ£¬¶ø²»Äܱ»ÈκÎÆäËüÀà ( °üÀ¨×ÓÀà ) ËùÒýÓá£
3 £©±£»¤·ÃÎÊ¿ØÖÆ·û protected £ºÓà protected ÐÞÊεijÉÔ±±äÁ¿¿ÉÒÔ±»ÈýÖÖÀàËùÒýÓ㺢ٸÃÀà×ÔÉí£»¢ÚÓëËüÔÚͬһ¸ö°üÖеÄÆäËüÀࣻ¢ÛÔÚÆäËü°üÖеĸÃÀàµÄ×ÓÀࡣʹÓÃÐÞÊηû protected µÄÖ÷Òª×÷ÓÃÊÇÔÊÐíÆäËü°üÖÐËüµÄ×ÓÀàÀ´·ÃÎʸ¸ÀàµÄÌض¨ÊôÐÔ¡£
4 £©Ë½Óб£»¤·ÃÎÊ¿ØÖÆ·û private protected £ºÓÃÐÞÊηû private protected ÐÞÊεijÉÔ±±äÁ¿¿ÉÒÔ±»¸ÃÀà±¾Éí»ò¸ÃÀàµÄ×ÓÀàÁ½ÖÖÀà·ÃÎʺÍÒýÓá£
5 £©¾²Ì¬ÓòÐÞÊηû static £ºÓà static ÐÞÊεijÉÔ±±äÁ¿½öÊôÓÚÀàµÄ±äÁ¿£¬¶ø²»ÊôÓÚÈκÎÒ»¸ö¾ßÌåµÄ¶ÔÏ󣬾²Ì¬³ÉÔ±±äÁ¿µÄÖµÊDZ£´æÔÚÀàµÄÄÚ´æÇøÓòµÄ¹«¹²´æ´¢µ¥Ôª£¬¶ø²»ÊDZ£´æÔÚijһ¸ö¶ÔÏóµÄÄÚ´æÇø¼ä¡£ÈκÎÒ»¸öÀàµÄ¶ÔÏó·ÃÎ
Ïà¹ØÎĵµ£º
Àà¼ÓÔØÆ÷ÊÇ Java ÓïÑÔµÄÒ»¸ö´´Ð£¬Ò²ÊÇ Java ÓïÑÔÁ÷ÐеÄÖØÒªÔÒòÖ®Ò»¡£ËüʹµÃ Java Àà¿ÉÒÔ±»¶¯Ì¬¼ÓÔص½ Java ÐéÄâ»úÖв¢Ö´ÐС£Àà¼ÓÔØÆ÷´Ó JDK 1.0 ¾Í³öÏÖÁË£¬×î³õÊÇΪÁËÂú×ã Java Applet µÄÐèÒª¶ø¿ª·¢³öÀ´µÄ¡£Java Applet ÐèÒª´ÓÔ¶³ÌÏÂÔØ Java ÀàÎļþµ½ä¯ÀÀÆ÷Öв¢Ö´ÐС£ÏÖÔÚÀà¼ÓÔØÆ÷ÔÚ Web ÈÝÆ÷ºÍ OSGi Öеõ½Á˹㷺µÄʹÓá ......
²Ù×÷·û
1.λ²Ù×÷·û
(a) >>>ÓÒÒÆ£¬¸ßλÓÃ0Ìî³ä£»
int a = 14;
int b = 2;
System.out.println(a >>> b);// 3
int c = -14;
int d = 2;
System.out.println(c >>> d);// 1073741820
(b) >>·ûºÅλ²»±ä£¬ÆäËûλÓÒÒÆ£¬¸ßλÓÃ0Ìî³ä£¬Æä½á¹ûÓëa/2bÏàͬ£»
int a = 14;
int b = 2;
Sy ......
½ñÌì¿´µ½Ä³ÍøÓѹØÓÚ“ÈçºÎÒÔJavaʵÏÖÍøÒ³½Øͼ¼¼Êõ”µÄ×ÉѯÌû£¬ÓÉÓÚ³öÏÖ¸Ã×ÉѯµÄµØµã·Ç³£²»ÊʺϽϳ¤»Ø¸´£¬¹ÊÒÔ²©ÎÄÐÎʽ»Ø´ð¡£
ÊÂʵÉÏ£¬Èç¹ûÄúÏëÒÔJavaʵÏÖÍøÒ³½Øͼ£¬Ò²¾ÍÊÇ“ÊäÈëÒ»¶ÎÍøÖ·£¬¼¸ÃëÖÓ¹ýºó¾ÍÄܽØÈ¡Ò»ÕÅÍøÒ³ËõÂÔͼ”µÄЧ¹û¡£ÄÇô£¬ÄúÖÁÉÙÓÐ3ÖÖ·½Ê½¿ÉÒÔÑ¡Ôñ¡£
1¡¢×îÖ±½ÓµÄ·½Ê½—— ......
±¾ÎĽéÉܵÄJAVA¹æÔòµÄ˵Ã÷·ÖΪ3¸öÖ÷Òª¼¶±ð£¬Öм¶ÊÇƽʱ¿ª·¢ÓõıȽ϶àµÄ¼¶±ð£¬ÔÚ½ñºó½«Â½Ðøд³öÆäËûµÄ¹æÔò¡£×ñÊØÁËÕâЩ¹æÔò¿ÉÒÔÌá¸ß³ÌÐòµÄЧÂÊ¡¢Ê¹´úÂëÓÖ¸üºÃµÄ¿É¶ÁÐԵȡ£
£¨1£© ÔÚfinally·½·¨Àï¹Øµôinput»òÕßoutput ×ÊÔ´
ÔÙ·½·¨ÌåÀïÃ涨ÒåÁËinput»òÕßoutputÁ÷µÄ»°£¬ÐèÒªÔÚfinallyÀïÃæ°ÑËü¹Øµô¡£
ÒÔÏÂ ......
import java.io.*;
/**
* linux ÏÂcpu ÄÚ´æ ´ÅÅÌ jvmµÄʹÓüà¿Ø
* @author avery_leo
*
*/
public class TT {
/**
* »ñÈ¡cpuʹÓÃÇé¿ö
* @return
&nbs ......