CSCI 431 — Java review plus more

Getting started

Action Ε: Getting more generic

Make you class into a generic Lollypop<T> with constructor arguments of type List<T>.

For now, you should just remove the constructor arguments for the integer array. We will get back to that one later.

Action Ζ: Testing generic

Test out your program by adding a second type, I suggest List<String>. You might find the following useful for your two arrays:

        String[] startNames   =
	    {"zero", "one", "two", "three", "four",
	     "five", "six", "seven", "eight", "nine" } ;
        String[] loopNames    =
	    {"ten", "eleven", "twelve", "thirteen", "fourteen",
	     "fifteen", "sixteen", "seventeen", "eightteen", "nineteen" } ;
  

Be sure to use both Integer and String in your program.

Action Η: Converting array to List

Get on the net and look up information about converting an array into an List. There are some wild answers out there. See if you can get any to work.

Be sure to save your old program before trying out these newfangled JDK 8+ features.

Action ?:

Next week we will look at some new things in JDK 8: Stream and Collectors.

Look at the whole tutorial on Nested Classes and pay attention to the section on Lambda Expressions. Also, read the Tutorial on Collections with a focus on Aggregate Operations. For more information look at the documentation for java.util.stream.