title: How to use Arrays.asList() method to return a list of objects?
body: <p>I'm setting up a RestController using Spring-boot. This project requires me to return a list of object (in this case objects of class Book). How do I do that?</p>
  
  <p>I've tried Arrays.asList() method by passing a object of class Book shown below:</p>
  
  <p><strong>java</strong></p>
  
  <pre><code>@RestController
  public class BookController {
  
      @GetMapping("/books")
      public List&lt;Book&gt; getAllBooks() {
  
          return Arrays.asList(new Book(1l, "Book name", "Book author"));
  
      }
  }
  </code></pre>
  
  <p><strong>java</strong></p>
  
  <pre><code>public class Book {
  
      Long id;
      String name;
      String author;
  
      public Book(Long id, String name, String author) {
          super();
          this.id = id;
          this.name = name;
          this.author = author;
      }
  
      public Long getId() {
          return id;
      }
  
      public String getName() {
          return name;
      }
  
      public String getAuthor() {
          return author;
      }
  
      @Override
      public String toString() {
          return "Book [id=" + id + ", name=" + name + ", author=" + author + "]";
      }
  }
  </code></pre>
  
  <p>I've got this error <code>"Type mismatch: cannot convert from List&lt;Object&gt; to List&lt;Book&gt;"</code>. How can I fix this?</p>