简体   繁体   中英

How to create a List of String field in Object Model class in java?

I am creating a Client class where one of the fields is array of String,How can I initialize it in the client model?

public class Client{
    @Id
        private String clientId;
        @NotBlank(message = "Client Name cannot be Blank")
        private String clientName;
        private String clientSecret;
        @NotBlank(message = "APIs Granted cannot be blank")
        private List<String> marks; // I am doing like this but gives an error.
        @NotBlank(message = "Status cannot be Blank")
        private String status;
        private String time;
}

The marks field is a list of string but its giving a error.Can someone help?

You can initialize a List<String> like this:

List<String> strs = Arrays.asList("Hello1", "Hello2");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM