how to declare list in java function code example Example: Define a list java List<MyType> myList = new ArrayList<>();