Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Java Native Method[»¹Ã»À´µÃ¼°·­Òë]

The goal for this chapter is to introduce you to Java's native methods. If you are new to Java, you may not know what native methods are, and even if you are an experienced Java developer, you may not have had a reason to learn more about native methods. At the conclusion of this chapter you should have a better understanding of what native methods are, when and why you may want to use them, and the consequences of using them. You should also have a basic understanding of how native methods work. You will then be more than ready to tackle the next three chapters, which dive into the nitty-gritty details of Java's Native Methods.
What Is a Native Method?
Simply put, a native method is the Java interface to non-Java code. It is Java's link to the "outside world." More specifically, a native method is a Java method whose implementation is provided by non-Java code, most likely C (see Figure 30.1). This feature is not special to Java. Most languages provide some mechanism to call routines written in another language. In C++, you must use the extern "C" stmt to signal that the C++ compiler is making a call to C functions. It is common to see the qualifier pascal in many C compilers to signal that the calling convention should be done in a Pascal convention, rather than a C convention. FORTRAN and Pascal have similar facilities, as do most other languages.
Figure 30.1 : A native method is a Java method whose implementation is provided by non-java code.
In Java, this is done via native methods. In your Java class, you mark the methods you wish to implement outside of Java with the native method modifier-much like you would use the public or static modifiers. Then, rather than supplying the method's body, you simply place a semicolon in its place. As an example, the following class defines a variety of native methods:
public class IHaveNatives
{
native public void Native1( int x ) ;
native static public long Native2() ;
native synchronized private float Nativ


Ïà¹ØÎĵµ£º

javaÖеĻù±¾Êý¾ÝÀàÐÍ


»ù±¾ÀàÐÍ£¬»òÕß½Ð×öÄÚÖÃÀàÐÍ£¬ÊÇJAVAÖв»Í¬ÓÚÀàµÄÌØÊâÀàÐÍ¡£ËüÃÇÊÇÎÒÃDZà³ÌÖÐʹÓÃ×îÆµ·±µÄÀàÐÍ£¬Òò´ËÃæÊÔÌâÖÐÒ²×ÜÉÙ²»ÁËËüÃǵÄÉíÓ°£¬ÔÚÕâÆªÎÄÕÂÖÐÎÒÃǽ«´ÓÃæÊÔÖг£¿¼µÄ¼¸¸ö·½ÃæÀ´»Ø¹ËÒ»ÏÂÓë»ù±¾ÀàÐÍÏà¹ØµÄ֪ʶ¡£
»ù±¾ÀàÐ͹²ÓаËÖÖ£¬ËüÃÇ·Ö±ð¶¼ÓÐÏà¶ÔÓ¦µÄ°ü×°Àà¡£¹ØÓÚËüÃǵÄÏêϸÐÅÏ¢Çë¿´ÏÂ±í£º
»ù±¾ÀàÐÍ¿ÉÒÔ·ÖΪÈýÀ࣬ ......

LinuxÏÂjava»·¾³±äÁ¿ÉèÖ÷½·¨

תÌù£º
ÏÖÔÚÓÃlinuxµÄÅóÓÑÔ½À´Ô½¶àÁË£¬Ç°¼¸Ìì¾ÍÓÐÁ½¸öÅóÓÑÎÊÎÒlinuxÏÂÔõôÅäÖÃjava»·¾³£¬ÎÒÏ뻹ÓкܶàÅóÓÑÏëÁ˽âѧϰÕâ·½ÃæµÄ¶«Î÷£¬¾Íдһ¸öÍêȫһµãµÄlinux java»·¾³ÅäÖðɣ¬Ï£Íû¶Ô´ó¼ÒÓаïÖú¡£
Ò». ÏÂÔØjdk5.0 for linux
¡¡¡¡µ½sunµÄÖ÷Ò³ http://java.sun.com/j2se/1.5.0/download.jsp ÏÂÔØjdk°²×°Îļþjdk-1_5_0_05-li ......

Java½â»ó2 25ÎÞÇéµÄÔöÁ¿²Ù×÷

ÏÂÃæµÄ³ÌÐò¶ÔÒ»¸ö±äÁ¿Öظ´µØ½øÐÐÔöÁ¿²Ù×÷£¬È»ºó´òÓ¡ËüµÄÖµ¡£ÄÇôÕâ¸öÖµÊÇÊ²Ã´ÄØ£¿
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);
}
}
Õ§Ò»¿´£¬Õâ¸ö³ÌÐò¿ÉÄÜ» ......

Java½â»ó2 27±ä»ÃβâµÄIÖµ

ÓëÃÕÌâ26ÖеijÌÐòÒ»Ñù£¬ÏÂÃæµÄ³ÌÐòÒ²°üº¬ÁËÒ»¸ö¼Ç¼ÔÚÖÕֹǰÓжàÉٴεü´úµÄÑ­»·¡£ÓëÄǸö³ÌÐò²»Í¬µÄÊÇ£¬Õâ¸ö³ÌÐòʹÓõÄÊÇ×óÒÆ²Ù×÷·û£¨<<£©¡£ÄãµÄÈÎÎñÕÕ¾ÉÊÇÒªÖ¸³öÕâ¸ö³ÌÐò½«´òӡʲô¡£µ±ÄãÔĶÁÕâ¸ö³ÌÐòʱ£¬Çë¼Çס Java ʹÓõÄÊÇ»ùÓÚ2µÄ²¹ÂëµÄ¶þ½øÖÆËãÊõÔËË㣬Òò´Ë-1ÔÚÈκÎÓзûºÅµÄÕûÊýÀàÐÍÖУ¨byte¡¢short¡¢int»òlong£ ......

java ÈÝÆ÷Àà С½á troy

JAVAµÄÈÝÆ÷---List,Map,Set
Collection
©ÀList
©¦©ÀLinkedList
©¦©ÀArrayList
©¦©¸Vector
©¦¡¡©¸Stack
©¸Set
Map
©ÀHashtable
©ÀHashMap
©¸WeakHashMap
Collection½Ó¿Ú
¡¡¡¡CollectionÊÇ×î»ù±¾µÄ¼¯ºÏ½Ó¿Ú£¬Ò»¸öCollection´ú±íÒ»×éObject£¬¼´CollectionµÄÔªËØ£¨Elements£©¡£Ò»Ð© CollectionÔÊÐíÏà ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ