One Java question every day [9], a java question

Source: Internet
Author: User

One Java question every day [9], a java question

Question

What is the role of the native keyword?

Answer

First, you need to understand JNI (Java Native Interface), which is an API connecting Java platform with local C code.

Second, the method declared with the native keyword is to tell JVM that the method called is an external defined method, that is, a method defined by local C code.

To sum up, the specific function of the native keyword is to use the method it declares without Java code implementation. Instead, the JVM uses JNI to load the local system C/C ++ DLL, and then calls the method to implement it.

Divergent thinking

1. Which method we usually use is declared with the native keyword?

Answer: hashCode method in java. lang. Object source code:

Public native int hashCode ();

2. When do we usually use the native keyword?

Answer:

And so on.

References

1. The role of the general Native keyword in Java (http://www.cnblogs.com/Qian123/p/5702574.html)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.