Skip to main content
The OP asked about both static methods and default methods on interfaces. The code ecample in the solution refers to default methods, and so it should state so.
Source Link

A good motivating example for default methods is in the Java standard library, where you now have

list.sort(ordering);

instead of

Collections.sort(list, ordering);

I don't think they could have done that otherwise without more than one identical implementation of List.sort.

A good motivating example is in the Java standard library, where you now have

list.sort(ordering);

instead of

Collections.sort(list, ordering);

I don't think they could have done that otherwise without more than one identical implementation of List.sort.

A good motivating example for default methods is in the Java standard library, where you now have

list.sort(ordering);

instead of

Collections.sort(list, ordering);

I don't think they could have done that otherwise without more than one identical implementation of List.sort.

added 7 characters in body
Source Link
soru
  • 3.7k
  • 24
  • 15

A good motivating example is in the Java standard library, where you now have

list.sort(ordering);

instead of

Collections.sort(list, ordering);

I don't youthink they could have done that otherwise without more than one identical implementation of List.sort.

A good motivating example is in the Java standard library, where you now have

list.sort(ordering);

instead of

Collections.sort(list, ordering);

I don't you could have done that otherwise without more than one identical implementation of List.sort.

A good motivating example is in the Java standard library, where you now have

list.sort(ordering);

instead of

Collections.sort(list, ordering);

I don't think they could have done that otherwise without more than one identical implementation of List.sort.

Source Link
soru
  • 3.7k
  • 24
  • 15

A good motivating example is in the Java standard library, where you now have

list.sort(ordering);

instead of

Collections.sort(list, ordering);

I don't you could have done that otherwise without more than one identical implementation of List.sort.