Java- native modifier / Chapter -8 / Access Modifier

java native modifier

java native modifier


1. "native" is a modifier applicable only for methods and we cannot apply anywhere else. 2. The methods which are implemented in non-java (C or C++) are called native methods. 3. The main objective of native modifier are:-



  • Improve performance of the system.

  • To achieve machine level or memory level communication.

  • To use already existing legacy (non-java) code.





4.For the native method, implementation is already available in the old language like C, C++ and we are not responsible for providing implementation hence native method declaration should end with ";" semicolon.




public native void m1( );       Valid

public native void m1( ) { }; Invalid



5.The main advantage of the native keyword performance will be improved but the main disadvantage of the native keyword is "It breaks the platform independent nature of Java".



No comments:

Post a Comment

Be the first to comment!

Don't just read and walk away, Your Feedback Is Always Appreciated. I will try to reply to your queries as soon as time allows.

Note:
1. If your question is unrelated to this article, please use our Facebook Page.
2. Please always make use of your name in the comment box instead of anonymous so that i can respond to you through your name and don't make use of Names such as "Admin" or "ADMIN" if you want your Comment to be published.

Regards,
JavaByChetan
Back To Home

Flipkart End Of Season Sale






© Copyright 2017 Javabychetan.blogspot.com