I just want to understand this Java Interface souce code
Posted on 2012-08-27
This is straight Java code:
public interface StockPriceService extends RemoteService
StockPrice getPrices(String symbols);
* Utility class for simplifying access to the instance of async service.
public static class Util
private static StockPriceServiceAsync instance;
public static StockPriceServiceAsync getInstance()
if (instance == null)
instance = GWT.create(StockPriceService.class);
-- I used to think an interface could not contain any instantiation code but surprise it appears it can almost like abstract class code.
Note the above so My question is does this Interface when implemented insert
an inner class into a given class that implements the Interface?
What does class AppleFun implements StockPriceService do?
Unlike typical interfaces witho classes ebedded will this in essence insert an inner class
definition in the same way an abstract class inserts specifically defined methods ?
Anotherwords does the above code mean that
AppleFun class has an inner static class called, Util exactly as deined above?
I had never seen anything like this with interfaces. Can anyone comment on this?
Or confirm my expecation that this inner class contained in an interface is part of any
class that implements the interface?
Does anyone find this code a bit odd? Maybe it was never covered in my JDK book or maybe its part of the 1.7 JDK standard and on part of the earlier standards.
Maybe I just never came across such a usage case before.