File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Legal Method Declarations II Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Legal Method Declarations II" Watch "Legal Method Declarations II" New topic

Legal Method Declarations II

Dan Mortimer

Joined: Jun 01, 2004
Posts: 18
I have the following code:

public abstract class TestAbstract {
abstract String specialMethod();

private native void abstractMethod();

void sayHello() {

It compiles fine, but I am a bit confused because I have an abstract method declaration which does not use the keyword abstract:

private native void abstractMethod();

The compiler is fine with the above decalration, but it doesnt't like the following:

String abstractMethod();, why can I get away without using the abstract keyword in the first method declaration and not the second...?

Richard Bradford
Ranch Hand

Joined: Apr 20, 2004
Posts: 48
The first method is legal because you have used the native keyword.
Methods that are declared as native do not contain a method body as they implemented elsewhere in a seperate language source file such as a c++ class file.
Dan Mortimer

Joined: Jun 01, 2004
Posts: 18
Thanks Richard!
I agree. Here's the link:
subject: Legal Method Declarations II
jQuery in Action, 3rd edition