title: Can you instantiate a Java class constructor with an untyped object?
body: <p>I'm coming from a Javascript background. I understand that in Java, to instantiate a class, you can provide multiple constructors to set the class variables. However, can you provide the constructor with an untyped object to initialise the class variables like below:</p>
  
  <pre><code>public class Book {
      String title;
      String author;
  
      public Book(Object data) {
          this.title = data.title;
          this.author = data.author;
      }
  }
  </code></pre>
  
  <p>So can I instantiate a new Book instance like:</p>
  
  <pre><code>Book bookOne = new Book({ title: "Book One", author: "Author One" });
  </code></pre>
  
  <p>The reason why I want to do this is because if a class has let's say more than 10 variables to be when initialised, it's difficult to instantiate a class reliably by giving a list of let's say 10 parameters.</p>