Linked Questions

3 votes
1 answer
632 views

Possible Duplicate: Why can’t I declare static methods in an interface? Inside the interface body we aren't able to declare or define any static method. What is the reason? Can any one ...
Vinoth Kumar's user avatar
  • 3,393
576 votes
24 answers
457k views

NOTE: This question predates Java 8. As of Java 8, static methods are allowed in interfaces. However, they cannot be declared abstract (required to be overridden) in the manner requested by this ...
cdmckay's user avatar
  • 32.4k
75 votes
5 answers
20k views

I understand that in Java static methods are inherited just like instance methods, with the difference that when they are redeclared, the parent implementations are hidden rather than overridden. Fine,...
user avatar
8 votes
4 answers
6k views

I was going through Effective Java and reading static factory methods for creating objects. Its chapter 2, Item 1. There in the advantage no. 3, the writer has mentioned like Hiding implementation ...
darkapple's user avatar
  • 549
12 votes
4 answers
6k views

Suppose I write a library with the following: public class Bar { /* ... */ } public class SomeWeirdClass<T> where T : ??? { public T BarMaker(Bar b) { // ... play with b ...
fostandy's user avatar
  • 4,402
3 votes
4 answers
2k views

I'm confused why the following is not allowed: public interface MyInterface { MyInterface getInstance(String name); } public class MyImplementation implements MyInterface { public ...
KidTempo's user avatar
  • 930
2 votes
6 answers
1k views

I'm just curious, wouldn't it be more convinient to allow interfaces to contain implementations of static methods? Such methods could contain short commonly used(by this interface implementors) logic.
Vladimir's user avatar
  • 13.2k
4 votes
1 answer
4k views

I'm interested in doing something like this: public interface Foo { public static "abstract" Bar SOME_BAR; // subclasses define one of these } and public interface Foo { public static "...
downer's user avatar
  • 964
0 votes
2 answers
2k views

I have written this java code public interface Sorter { public static <T extends Comparable<T>> void sort(T[] array); } and the compiler throws this error at me: Sorter.java:7: ...
Theo Stefou's user avatar
1 vote
3 answers
1k views

Consider the followoing code interface MyInterface{ void method(String s);// if we write static modifier we have compile error } class MyClass implements MyInterface{ public static void main(...
St.Antario's user avatar
  • 27.7k
1 vote
4 answers
901 views

I have a design question. I have an interface that read XML. Each implementer class read different XML and I want a way to identify which implementer should I dynamically create for the xml type I ...
user3369398's user avatar
1 vote
4 answers
183 views

I have a protocol called Social Service, declared as follows: protocol SocialService: class { class func testFunc() } A class that follows the protocol may look like this: class Twitter: ...
Andrew's user avatar
  • 7,913
4 votes
3 answers
227 views

I defined an interface IPersistent that has two methods load and save. Using these methods I can load or save the implementing class using whatever method they want. public interface IPersistent { ...
Bart Friederichs's user avatar
0 votes
2 answers
153 views

Say I have some class that is too fat of methods for one concrete case, but fits to about a half of them, so it is no way but to extend it. Simultaneously, I want to hide the fact that I've extended ...
shaman.sir's user avatar
  • 3,328
1 vote
3 answers
134 views

I Have a UserEntity class which implements the IUserEntity interface. In the UserEntity class I have a static map: private static Map<IUserEntity.IIdentifiable, IUserEntity> ...
Maxime Gajovski's user avatar

15 30 50 per page