• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reg. native methods

 
Angela Narain
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is the below declaration valid :
public static native void methodA() ;
 
Gagan Indus
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes , native methods can be static
( they can never be abstract )
------------------
Gagan (/^_^\)
 
Angela Narain
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are nt' native methods by default abstract ?
 
Amit Agrawal
Ranch Hand
Posts: 282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no they are not [abstract].
 
Jane Griscti
Ranch Hand
Posts: 3141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Angela,
'abstract' tells the compiler the method isn't implemented by the class and must be implemented by any subclasses.
'native' tells the compiler that the method does not require implementation because it will be available from the operating system. In other words, it's not 'abstract', it is implemented, just not in Java.
You'll get a compile error if you declare a method to be both 'native' and 'abstract'. See JLS �8.4.3.4
Hope that helps.
------------------
Jane Griscti
Sun Certified Programmer for the Java� 2 Platform
[This message has been edited by Jane Griscti (edited September 15, 2001).]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic