
-----------------------------------
np_123
Mon Jan 18, 2016 11:02 pm

Instantiating an interface
-----------------------------------
So I know some stuff about coding in Java, and the basics of how encapsulation and other OOP concepts work, but this code excerpt(not my own) kinda surprised me...
You can't instantiate abstract classes and you can't instantiate regular interfaces so what's so special about a nested/inner interface that allows this code to run? Also, when and why would you instantiate an interface?


public class Shuffler {

	public interface IShuffle{
		public void shuffle(int

-----------------------------------
Insectoid
Tue Jan 19, 2016 6:30 pm

RE:Instantiating an interface
-----------------------------------
looks like this has been answered [url=http://stackoverflow.com/questions/4587392/can-we-create-an-instance-of-an-interface-in-java]here.

-----------------------------------
np_123
Tue Jan 19, 2016 6:49 pm

RE:Instantiating an interface
-----------------------------------
hmm, yeah that's interesting. haven't really come across that type of usage before
