Home > Back-end >  List.of() method not found in spring boot application error
List.of() method not found in spring boot application error

Time:07-13

  1. I checked all imports they are correct the only error I am getting is while calling the List.of() method.
UserDao user1 = new UserDao();
user1.setName("j");
user1.setUser_name("k");
user1.setPassword("l");
user1.setPhone("86632");
    
UserDao user2 = new UserDao();
user1.setName("j");
user1.setUser_name("k");
user1.setPassword("l");
user1.setPhone("86632");
  1. Here the of method is not found in spring tool suite I am on jre1.8
List<UserDao> users = List.of(user1, user2);
Iterable<UserDao> itrb = userRepo.saveAll(users);

CodePudding user response:

List.of is introduced starting from Java 9. So that you have to upgrade your Java to make use of one.

CodePudding user response:

You need atleast Java 9 for using List.of() function https://docs.oracle.com/javase/9/docs/api/java/util/List.html#immutable

CodePudding user response:

You should upgrade to Java9 to use List.of function, or use Arrays.asList instead.

  • Related