Answers for "can an interface have static methods"

2

can interface have static methods

no, interfaces cannot have static or final methods.
Posted by: Guest on September-13-2021
0

How many static methods can an interface have?

package com.journaldev.java8.staticmethod;

public interface MyData {

	default void print(String str) {
		if (!isNull(str))
			System.out.println("MyData Print::" + str);
	}

	static boolean isNull(String str) {
		System.out.println("Interface Null Check");

		return str == null ? true : "".equals(str) ? true : false;
	}
}
Posted by: Guest on March-24-2020

Code answers related to "can an interface have static methods"

Browse Popular Code Answers by Language