Java - Indexing an Interface? -


this stupid question, please forgive me. morning, i've come across piece of java syntax unfamiliar with. syntax follows:

public myinterface[] getthings() {     return new myinterface[0]; } 

obviously, i've changed name of interface, , of method, otherwise code sample unchanged.

i'm confused syntax, seems indexing interface/class (not object)?! also, use of new keyword, instantiate interface?!

i've genuinely attempted google this, in order find answer. it's syntax i'm unfamiliar with, in addition using line of code search term, i've been guessing @ terminology use. , unfortunately, i've failed find explains syntax me. hence, i'm hoping on stack overflow might kind enough me understand this.

it's creating empty array. no instances of interface being created. it's equivalent to:

return new myinterface[] { }; 

or:

myinterface[] array = {}; return array; 

specifically, it's arraycreationexpression, seen in section 15.10 of jls.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -