+1 vote
in JAVA by
What is a Static Method? Why do we need Static methods in Java 8 Interfaces?

1 Answer

0 votes
by

A Static Method is a Utility method or Helper method, which is associated with a class (or interface). It is not associated with any object.

We need Static Methods because of the following reasons:

We can keep Helper or Utility methods specific to an interface in the same interface rather than in a separate Utility class.

We do not need separate Utility Classes like Collections, Arrays, etc to keep Utility methods.

Clear separation of Responsibilities. That is we do not need one Utility class to keep all Utility methods of Collection API like Collections etc.

  1. Easy to extend the API.
  2. Easy to Maintain the API.

Related questions

+2 votes
asked May 31, 2020 in JAVA by SakshiSharma
0 votes
asked Oct 13, 2020 in JAVA by SakshiSharma
...