LPD
LPD

Reputation: 2883

Returning Void from a RequestContext method

Can a method present in the RequestContext method return void?

If my RequestContext looks like this,

@Service( value = PersonUtil.class, locator = PersonLocator.class )
public interface PersonRequest extends RequestContext
{

    Request<void> testMethod( Long id );
    ......
}

I am getting this error:

Multiple markers at this line - Return type for the method is missing - Syntax error on token "void", Dimensions expected after

Can we not create a method with return type void? If not, why is it so?

Thanks in advance.

Upvotes: 0

Views: 81

Answers (1)

Thomas Broyer
Thomas Broyer

Reputation: 64541

void is just like primitive types like int or boolean, you can't use it as a type parameter.

And just like you'd use Integer instead of int, you'll use Void here (java.lang.Void)

Upvotes: 1

Related Questions