Declare and use List in java -


i touch java, found if need create new list

list<string> = new arraylist<string>(); 

but in homework, code following. in function postering, parameter list<integer> positions . can put 'arraylist' there? or usually put list there?

could explain in detailed way?

static class posting { int docid; list<integer> positions; public posting(int docid, list<integer> positions) {   this.docid = docid;   this.positions = positions; } 

}

list<integer> interface; arraylist<integer> class implementing interface. should use list<integer>, because lets caller change implementation - example, linkedlist<integer>.

this technique improving flexibility known programming interface. can read more advantages in answers question.


Comments

Popular posts from this blog

hibernate - How to load global settings frequently used in application in Java -

python 3.x - Mapping specific letters onto a list of words -

objective c - Ownership modifiers with manual reference counting -