Java Interfaces, methods need to return something?

(1st post don't bully me :D)

My question is simple, is it imperative that a method included in an interface HAS to return some value? (int, double, String etc..) Cause last time I checked I could not define a Void method in an interface, got compiling errors.

Thanks in advance! Cheers!

Jon Skeet
people
quotationmark

My question is simple, is it imperative that a method included in an interface HAS to return some value?

No, absolutely not.

You can declare a void method in an interface, and indeed there are plenty of standard library interfaces with such methods. Runnable is a fine example:

public interface Runnable() {
    void run();
}

Note that declaring that a method returns Void is a different matter, and usually a mistake. (It's primarily useful for generic methods where you're going to return a value of type T - for example, Runnable is similar to Callable<Void>.)

people

See more on this question at Stackoverflow