Static Method in Interface

Since Java 8, we can have static method in interface. Let's see an example:

File: TestInterfaceStatic.java


\begin{lstlisting}
interface Drawable{
void draw();
static int cube(int x){r...
...e();
d.draw();
System.out.println(Drawable.cube(3));
}
}
\end{lstlisting}

Output:


\begin{lstlisting}
drawing rectangle
27
\end{lstlisting}