jtht
jtht

Reputation: 813

Can you have unimplemented java methods in your class body(similar to python pass)?

I'm writing a class and I find it helpful to have functions I have yet to implement in the class I'm working in, so if I'm making a stack for ints I could write something like:

public class Stack
{
    ...

    private void push(int n) {}

    private int pop() {}

    ...
}

just as a reminder of functionality I'm supporting and organizational purposes. Is this somehow possible? I keep getting compile time errors when I try.

The functionality I'm looking for is similar to python's pass statement like:

def f():
    pass

Upvotes: 1

Views: 1102

Answers (1)

Brian Roach
Brian Roach

Reputation: 76908

The conventional way, which the Netbeans IDE will do automatically when implementing an interface or extending an abstract class to provide placeholders, is to do:

private void push(int n) {
    throw new UnsupportedOperationException("not implemented yet");
}

Upvotes: 1

Related Questions