java中native关键字
发布时间:2020-12-14 06:39:11 所属栏目:Java 来源:网络整理
导读:p style="color:rgb(51,51,51);font-family:Arial;line-height:26px;" span style="font-size:12px;"今天研究Java基础类库,Object类的时候,发现了一个关键字:native p style="color:rgb(51,51);font-family:Arial;line-height:26px;" span style="font-si
<p style="color:rgb(51,51,51);font-family:Arial;line-height:26px;"> <p style="color:rgb(51,51);font-family:Arial;line-height:26px;"> <span style="font-size:12px;">咦?这是个什么东东?它认识我,我可不认识它! <p style="color:rgb(51,51);font-family:Arial;line-height:26px;"> <span style="font-size:12px;">嘿嘿,没关系,baidu一下。 <p style="color:rgb(51,51);font-family:Arial;line-height:26px;"> <span style="font-size:12px;">? <p style="color:rgb(51,51);font-family:Arial;line-height:26px;"> <span style="font-size:12px;">java native关键字 <p style="color:rgb(51,51);font-family:Arial;line-height:26px;"> <span style="font-size:12px;">?一. 什么是Native Method ?? 简单地讲,一个Native Method就是一个java调用非java代码的接口。一个Native Method是这样一个java的方法:该方法的实现由非java语言实现,比如C。这个特征并非java所特有,很多其它的编程语言都有这一机制,比如在C++中,你可以用extern "C"告知C++编译器去调用一个C的函数。 ???<span style="color:rgb(128,0);">"A native method is a Java method whose implementation is provided by non-java code."?? 在定义一个native method时,并不提供实现体(有些像定义一个java interface),因为其实现体是由非java语言在外面实现的。,下面给了一个示例:??? <div class="highlighter dp-highlighter" style="font-family:Consolas,'Courier New',Courier,mono,serif;overflow:auto;color:rgb(51,51);line-height:26px;"> <ol class="highlighter-c" style="border:none;color:rgb(92,92,92);"> <li style="list-style:outside;border-style:none none none solid;border-left-width:3px;border-left-color:rgb(108,226,108);line-height:18px;"> <span style="border:none;color:#000000;"><span style="font-size:12px;">package?java.lang;? (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |