Java½â»ó3 26ÔÚÑ»·ÖÐ
ÏÂÃæµÄ³ÌÐò¼ÆËãÁËÒ»¸öÑ»·µÄµü´ú´ÎÊý£¬²¢ÇÒÔÚ¸ÃÑ»·ÖÕֹʱ½«Õâ¸ö¼ÆÊýÖµ´òÓ¡Á˳öÀ´¡£ÄÇô£¬Ëü´òÓ¡µÄÊÇʲôÄØ£¿
public class InTheLoop {
public static final int END = Integer.MAX_VALUE;
public static final int START = END - 100;
public static void main(String[] args) {
int count = 0;
for (int i = START; i <= END; i++)
count++;
System.out.println(count);
}
}
Èç¹ûÄãûÓзdz£×ÐϸµØ²é¿´Õâ¸ö³ÌÐò£¬Äã¿ÉÄÜ»áÈÏΪËü½«´òÓ¡100£¬ÒòΪEND±ÈSTART´ó100¡£Èç¹ûÄãÉÔ΢×Ðϸһµã£¬Äã¿ÉÄܻᷢÏָóÌÐòûÓÐʹÓõäÐ͵ÄÑ»·¹ßÓ÷¨¡£´ó¶àÊýµÄÑ»·»áÔÚÑ»·Ë÷ÒýСÓÚÖÕֵֹʱ³ÖÐøÔËÐУ¬¶øÕâ¸öÑ»·ÔòÊÇÔÚÑ»·Ë÷ÒýСÓÚ»òµÈÓÚÖÕֵֹʱ³ÖÐøÔËÐС£ËùÒÔËü»á´òÓ¡101£¬¶ÔÂð£¿
àÅ£¬¸ù±¾²»¶Ô¡£Èç¹ûÄãÔËÐиóÌÐò£¬¾Í»á·¢ÏÖËüѹ¸ù¾Íʲô¶¼Ã»ÓдòÓ¡¡£¸üÔãµÄÊÇ£¬Ëü»á³ÖÐøÔËÐÐÖ±µ½Äã³·ÏúËüΪֹ¡£Ëü´ÓÀ´¶¼Ã»Óлú»áÈ¥´òÓ¡count£¬ÒòΪÔÚ´òÓ¡ËüµÄÓï¾ä֮ǰ²åÈëµÄÊÇÒ»¸öÎÞÏÞÑ»·¡£
ÎÊÌâÔÚÓÚÕâ¸öÑ»·»áÔÚÑ»·Ë÷Òý£¨i£©Ð¡ÓÚ»òµÈÓÚInteger.MAX_VALUEʱ³ÖÐøÔËÐУ¬µ«ÊÇËùÓеÄint±äÁ¿¶¼ÊÇСÓÚ»òµÈÓÚInteger.MAX_VALUEµÄ¡£ÒòΪËü±»¶¨ÒåΪËùÓÐintÊýÖµÖеÄ×î´óÖµ¡£µ±i´ïµ½Integer.MAX_VALUE£¬²¢ÇÒÔٴα»Ö´ÐÐÔöÁ¿²Ù×÷ʱ£¬Ëü¾ÍÓÐÈƻص½ÁËInteger.MIN_VALUE¡£
Èç¹ûÄãÐèÒªµÄÑ»·»áµü´úµ½intÊýÖµµÄ±ß½ç¸½½üʱ£¬Äã×îºÃÊÇʹÓÃÒ»¸ölong±äÁ¿×÷Ϊѻ·Ë÷Òý¡£Ö»Ð轫ѻ·Ë÷ÒýµÄÀàÐÍ´Óint¸Ä±äΪlong¾Í¿ÉÒÔ½â¾ö¸ÃÎÊÌ⣬´Ó¶øʹ³ÌÐò´òÓ¡³öÎÒÃÇËùÆÚÍûµÄ101£º
for (long i = START; i <= END; i++)
¸üÒ»°ãµØ½²£¬ÕâÀïµÄ½Ìѵ¾ÍÊÇint²»ÄܱíʾËùÓеÄÕûÊý¡£ÎÞÂÛÄãÔÚºÎʱʹÓÃÁËÒ»¸öÕûÊýÀàÐÍ£¬¶¼ÒªÒâʶµ½Æä±ß½çÌõ¼þ¡£Èç¹ûÆäÊýÖµÏÂÒç»òÊÇÉÏÒçÁË£¬»áÔõôÑùÄØ£¿ËùÒÔͨ³£×îºÃÊÇʹÓÃÒ»¸öÈ¡Ö®·¶Î§¸ü´óµÄÀàÐÍ¡££¨ÕûÊýÀàÐÍ°üÀ¨byte¡¢char¡¢short¡¢intºÍlong¡££©
²»Ê¹ÓÃlongÀàÐ͵ÄÑ»·Ë÷Òý±äÁ¿Ò²¿ÉÒÔ½â¾ö¸ÃÎÊÌ⣬µ«ÊÇËü¿´ÆðÀ´²¢²»ÄÇôƯÁÁ£º
int i = START;
do {
count++;
}while (i++ != END);
Èç¹ûÇåÎúÐԺͼò½àÐÔÕ¼¾ÝÁ˼«ÆäÖØÒªµÄµØ룬ÄÇôÔÚÕâÖÖÇé¿öÏÂʹÓÃÒ»¸ölongÀàÐ͵ÄÑ»·Ë÷Òý¼¸ºõ×ÜÊÇ×î¼Ñ·½°¸¡£
µ«ÊÇÓÐÒ»¸öÀýÍ⣺Èç¹ûÄãÔÚËùÓеģ¨»òÕß¼¸ºõËùÓеģ©intÊýÖµÉϵü´ú£¬ÄÇôʹÓÃintÀàÐ͵ÄÑ»·Ë÷ÒýµÄËٶȴóÔ¼¿ÉÒÔÌá¸ßÒ»±¶¡£ÏÂÃæÊǽ«fº¯Êý×÷ÓÃÓÚËùÓÐ40ÒÚ¸öintÊýÖµÉϵĹßÓ÷¨£º
//Apply the function f to all four billion
Ïà¹ØÎĵµ£º
class EnclosingOne {
public class InsideOne {
}
}
public class B {
public static void main(String[] args) {
EnclosingOne eo = new EnclosingOne();
EnclosingOne.InsideOne ei = eo.new InsideOne();
}
} ......
ÖÚËùÖÜÖª£¬JavaÓïÑÔÊÇÒ»Ãŷdz£ÊʺÏÍøÂ翪·¢µÄÓïÑÔ£¬Óà JavaÓïÑÔ½øÐÐÐÔÄܲâÊԽű¾¿ª·¢½«»á´ó´óÌá¸ß²âÊÔ¿ª·¢Ð§ÂÊ¡£LoadRunnerÖÐÌṩÁ˶ÔJavaÐéÄâÓû§µÄÖ§³Ö¡£JavaÐéÄâÓû§ÒÀÍÐÓÚJDK£¬Õâ´ó´óÀ©³äÁËLoadRunnerµÄ½Å±¾¿ª·¢¹¦ÄÜ¡£²âÊÔÈËÔ±¼È¿ÉÒÔÓÃJavaÐéÄâÓû§À´²âÊÔ»ùÓÚJavaµÄÓ¦ÓÃϵͳµÄÐÔÄÜ£¬ÓÖ¿ÉÒÔʹÓÃJavaÓïÑÔµÄÇ¿´ó¿ª·¢½Å±¾ ......
Ñ×ÈȵÄÌìÆøÒÀ¾É³ÖÐø£¬ÆþÖ¸ËãÀ´£¬µ½±±¾©¸ÕºÃÁ½ÔÂÁË£¬Ã¿Ì춼ͶÈëµ½³äʵµÄѧϰÖУ¬
¸Ð¾õÁ¼ºÃ£¬²»¹ý×òÌìÉϿξ¹È»Ë¯¾õ£¬¶øÇÒÍíÉÏ»¹¿´Á˵çÓ°¡£¡£¡£¡£¡£Òª±£³Ö¾¯Ì裬·ÅËÉ
µ«ÊDz»ÄÜÌ«·ÅËÉ£¡£¡£¡£¡
ÅàѵµÄʱ¼ä±Ï¾¹ºÜ¶Ì£¬´í¹ýÁËÕ⼸¸öÔ£¬ÒÔºó¹À¼Æ¾ÍºÜÉÙÄܾ²ÏÂÐÄÀ´Ñ§Ï°ÁË£¬ÒªÕäϧ£¬
ҪŬÁ¦£¬GOGO!!
JSPÒì³£´¦Àí·½Ê½£º
µÚ ......
±¾ÃÕÌâÀûÓÃÁËJava±à³ÌÓïÑÔÖÐÒ»¸öºÜÉÙ±»ÈËÁ˽âµÄÌØÐÔ¡£Ç뿼ÂÇÏÂÃæµÄ³ÌÐò½«»á×öЩʲô£¿
public class BrowserTest {
public static void main(String[] args) {
System.out.print("iexplore:");
http://www.google.com;
System.out.println(":maximize");
}
}
ÕâÊÇÒ»¸öÓеã¹îÒìµÄÎ ......
ÏÂÃæµÄ³ÌÐò¶ÔÒ»¸ö±äÁ¿Öظ´µØ½øÐÐÔöÁ¿²Ù×÷£¬È»ºó´òÓ¡ËüµÄÖµ¡£ÄÇôÕâ¸öÖµÊÇʲôÄØ£¿
public class Increment {
public static void main(String[] args) {
int j = 0;
for (int i = 0; i < 100; i++)
j = j++;
System.out.println(j);
}
}
Õ§Ò»¿´£¬Õâ¸ö³ÌÐò¿ÉÄÜ» ......