Oliver Williams
Oliver Williams

Reputation: 6364

beginner java syntax in calling method

I am new to Java, coming from PHP. Here is a snippet of code:

public List<WSOrderInfo> getOrderInfoList() {

    List<WSOrderInfo> detailList = new ArrayList<WSOrderInfo>();

I am wondering the following: What is the term in the angle brackets? (<WSOrderInfo>) Is this defined as part of some scope of the class? Does it reference an external variable?

Thanks!

Upvotes: 2

Views: 64

Answers (1)

Patrick Wei&#223;
Patrick Wei&#223;

Reputation: 456

As already mentioned in the comments these terms are specifying the type of objects your list contains. First, you should specify the concrete list, here ArrayList in your case. You may take a look at the List Interface to get familiar with.

You should also know that in Java generic type arguments must be objects and because primitives do not extend Object they can not be used. So use e.g. List<Integer> instead of List<int>, since the first one is the wrapper class of int. Just take a look at Wrapper Classes.

Hope this helps you to get more familiar with the topic.

Upvotes: 2

Related Questions