Wednesday, 2 March 2016

Helsinki MOOC - Method and object logistics



This week (week 3) starts off with an introduction to variables given to methods as parameters. Primitive type variables are copied as-is (the actual value), while reference type variables only copy the reference and give it to the method. It also talked about how methods can be used to assign work more easily, for example, having a lone method just for working out an average.
Again, the first few exercise started off simple. They were about using separate methods for the calculation of the largest/least number (of 3), average, and the sum.

The course then introduces ArrayList objects. These lists are used to store objects, which makes it easier when there are several objects to handle. The next two exercises used the methods of the list, plus the use of a for loop (for(String word: words)) to print out the contents of a String ArrayList.

The last exercise is quite popular for programming courses, the aim was to tell the user if the text they inputted was a palindrome or not. The goal of the exercise was for you to use different methods, which then called other methods. As well as this, the methods of the String object were used to reverse the text.