O'Reilly logo
  • You Wang thinks this is interesting:

Here is another common use for static methods. Classes such as LocalDate and NumberFormat use static factory methods that construct objects. You have already seen the factory methods LocalDate.now and LocalDate.of. Here is how the NumberFormat class yields formatter objects for various styles:


Cover of Core Java® Volume I—Fundamentals, Tenth Edition


factory methods can return instances of different kinds