ÈçºÎÈ¡µÄJavaÔ´´úÂëÎļþÖÐÎļþÃûºÍÐкÅ
ÈçºÎÈ¡µÄJavaÔ´´úÂëÎļþÖÐÎļþÃûºÍÐкţº£©
ÔÚC/C++µÄ³ÌÐò£¬±àÒëÆ÷ÌṩÁËÁ½¸öºêÀ´Ö§³ÖÈ¡µÃÔ´ÎļþÖеÄÐкźÍÎļþÃû£¬ÕâÁ½¸öºêÊÇ__FILE__,__LINE__
Äã¿ÉÒÔÈçϵķ½·¨´òÓ¡ÐкźÍÎļþÃû
²é¿´Ô´´úÂë
´òÓ¡°ïÖú
1 #include <stdio.h>
2 int main()
3 {
4 fprintf(stdout,"[%s:%d] Hello World!",__FILE__,__LINE__);
5 return 0;
6 }
µ«ÊÇÔÚJAVAÏÂûÓÐÕâÁ½¸öºê£¬ÄÇôÎÒÃÇÈçºÎÀ´È¡µÃÎļþÃûºÍÐкţ¬·ÔÄJDK£¬ÎÒÃÇÕÒµ½StackTraceElementÕâ¸öÀà¡£Õâ¸öÀà¿ÉÒÔ´ÓThrowableÈ¡µÃ£¬ÁíÍâÒ²¿ÉÒÔ´ÓThreadÀàÈ¡µÃ£¬Í¨¹ýÕâЩÎÒдÈçϵÄÒ»¸ö´òÓ¡ÐкŵIJâÊÔ³ÌÐò£º
²é¿´Ô´´úÂë
´òÓ¡°ïÖú
01 public class LineNo {
02 public static int getLineNumber() {
03 return Thread.currentThread().getStackTrace()[2].getLineNumber();
04 }
05
06 public static String getFileName() {
07 return Thread.currentThread().getStackTrace()[2].getFileName();
08 }
09 public static void main(String args[]) {
10 System.out.println("["+getFileName()+"£º"+ getLineNumber()+"]"+"Hello World!");
11 }
12 }
ÁôÏÂÒ»¸öÎÊÌ⣬ÉÏÃæ³ÌÐòÖеÄmagicÊý×Ö 2 ´ú±íʲôº¬ÒåÄØ£¿
0ÊÇthread.getCurrentThread()
1ÊÇgetLineNumber()
2²ÅÊǵ÷ÓÃgetLineNumberµÄÀà
Ïà¹ØÎĵµ£º
Java NIO APIÏê½â
ÔÚJDK
1.4ÒÔÇ°£¬JavaµÄIO²Ù×÷¼¯ÖÐÔÚjava.ioÕâ¸ö°üÖУ¬ÊÇ»ùÓÚÁ÷µÄ×èÈû£¨blocking£©API¡£¶ÔÓÚ´ó¶àÊýÓ¦ÓÃÀ´Ëµ£¬ÕâÑùµÄAPIʹÓúܷ½
±ã£¬È»¶ø£¬Ò»Ð©¶ÔÐÔÄÜÒªÇó½Ï¸ßµÄÓ¦Óã¬ÓÈÆäÊÇ·þÎñ¶ËÓ¦Óã¬ÍùÍùÐèÒªÒ»¸ö¸üΪÓÐЧµÄ·½Ê½À´´¦ÀíIO¡£´ÓJDK 1.4Æð£¬NIO
API×÷Ϊһ¸ö»ùÓÚ»º³åÇø£¬²¢ÄÜÌṩ·Ç×èÈû(non-blo ......
Ò»¡¢PythonÖеÄÎļþ¹ÜÀí
Îļþ¹ÜÀíÊǺܶàÓ¦ÓóÌÐòµÄ»ù±¾¹¦ÄܺÍÖØÒª×é³É²¿·Ö¡£Python¿ÉÒÔʹÎļþ¹ÜÀí¼«Æä¼òµ¥£¬ÌرðÊǺÍÆäËüÓïÑÔÏà¶Ô±È¡£
ÒÔÏ£¬Peyton McCullough½²½âÁËÎļþ¹ÜÀí»ù´¡¡£
½éÉÜ
ÄãÍæ¹ýµÄÓÎϷʹÓÃÎļþÀ´±£´æ´æµµ£»ÄãϵĶ©µ¥±£´æÔÚÎļþÖУ»ºÜÃ÷ÏÔ£¬ÄãÔçÉÏдµÄ±¨¸æÒ²±£´æÔÚÎļþÖС£
¼¸ºõÒÔÈκÎÓïÑÔ±àдµÄÖÚ¶àÓ ......
¹ØÓÚJavaÕ»Óë¶ÑµÄ˼¿¼
1. Õ»(stack)Óë¶Ñ(heap)¶¼ÊÇJavaÓÃÀ´ÔÚRamÖдæ·ÅÊý¾ÝµÄµØ·½¡£ÓëC++²»Í¬£¬Java×Ô¶¯¹ÜÀíÕ»ºÍ¶Ñ£¬³ÌÐòÔ±²»ÄÜÖ±½ÓµØÉèÖÃÕ»»ò¶Ñ¡£
¡¡¡¡2. Õ»µÄÓÅÊÆÊÇ£¬´æÈ¡ËٶȱȶÑÒª¿ì£¬½ö´ÎÓÚÖ±½ÓλÓÚCPUÖеļĴæÆ÷¡£µ«È±µãÊÇ£¬´æÔÚÕ»ÖеÄÊý¾Ý´óСÓëÉú´æÆÚ±ØÐëÊÇÈ·¶¨µÄ£¬È±·¦Áé»îÐÔ¡£ÁíÍ⣬ջÊý¾Ý¿ÉÒÔ¹²Ïí£¬Ïê¼ûµÚ3µ ......
java¼¯ºÏ¿ò¼Üͼ¼°½éÉÜ
ת×Ô:http://hi.baidu.com/%C9%AE_%CC%C6/blog/item/9e2a8b0887008a8ad0581b3d.html
¼ò»¯Í¼£º
Javaƽ̨ÌṩÁËÒ»¸öȫеļ¯ºÏ¿ò¼Ü¡£“¼¯ºÏ¿ò¼Ü”Ö÷ÒªÓÉÒ»×éÓÃÀ´²Ù×÷¶ÔÏóµÄ½Ó¿Ú×é³É¡£²»Í¬½Ó¿ÚÃèÊöÒ»×鲻ͬÊý¾ÝÀàÐÍ¡£
Java 2¼¯ºÏ¿ò¼Üͼ
¼¯ºÏ½Ó¿Ú£º6¸ö½Ó¿Ú£¨¶ÌÐéÏß±íʾ£©£¬±íʾ²»Í ......
ͨË×Àí½âÏòÉÏתÐÍ£º
¾ÍÊÇ×ÓÀàתÐͳɸ¸Àà¡£
class A{}
class B extends A { }
A b = new B();
Õâ¸ö¾ÍÊÇÏòÉÏתÐÍ¡£
ÏòÉÏתÐÍ¿ÉÒÔÏñÏÂÃæÕâÌõÓï¾äÕâô¼òµ¥:
Shape s =new Circle();
ÕâÀ´´½¨Ò»¸öCircle¶ÔÏ ......