0

I was looking for Spring form validation tutorial Yesterday, an from one of those i found this lines

String message() default "{Phone}";

Class<?>[] groups() default {};

Class<? extends Payload>[] payload() default {};

the above code was for phone number field validation,If any one can explain those lines that will be helpful ,i am not asking anything about validation,( I am confuse because those are neither function nor instance as far as i think ) i never have seen these type of code in java before.

1 Answer 1

1

Those are elements of some annotation declaration, eg

@interface A {
    String message() default "{Phone}";
    Class<?>[] groups() default {};
    Class<? extends Payload>[] payload() default {};

}

and this is how it can be used

@A(message = "Email", payload = {Payload.class})
class Test1 {
}

the above annotation will have default groups value = empty Class array

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.