A Week in Review: October 24-30

 

 

This week was all about lists. As far as I know, there is only one type of list in Python. As I found out this week, though, that’s far from the case with Java.  When I started out the week, I strongly disliked the implementation in lists and much preferred Python’s version.  Now that I have a bit of experience under my belt, I am not so intimidated by Java’s lists, and am finding myself missing Python’s less with each passing day.

Arrays

This is the first type of list I worked through.  The first thing that surprised me with arrays is that you must declare how many items are in your array before you enter the values in the list.  Coming from Python’s lists, I was shocked that an array could not simply grow or shrink as needed.  Another thing I was not pleased with is the amount of extra code it takes for Java to populate an array.  Instead of being able to set an array using a range function, you must (at least, as far as I am aware at the current time) use something like a for loop to accomplish this task.

pumpkin_fixed
Took some time out of my programming to carve pumpkins with friends. I thought this one was pretty fitting.

Array Lists

Many of the concerns I had with arrays were alleviated when I began to study ArrayLists.  These are lists that do not require the programmer to declare length.  I learned about the size(), get(), and equal() functions.  I grew extremely familiar with for loops during this section, as all of my challenge projects required plenty.  I was fascinated that I could create a list of objects using ArrayLists. I was surprised to hear that I could not natively pass in primitive data types (int, double, float, etc) to the ArrayLists, but the lecture on autoboxing was helpful in walking me through how to work around that.

Linked Lists

I found myself (quite surprisingly) interested as I sat through a two-part lecture describing how Java stores and retrieves objects in a list.  Tim Buchalka does a tremendous job explaining how lists work with memory addresses, highlighting the problem when a programmer is working with lists of hundreds of thousands of entries and the resources it requires to simply delete one single item.  This is where linked lists come in.  Rather than storing each entry in a sequential memory address, forcing the computer to copy and move every single entry if one is added or deleted, linked lists store each entry with a pointer to the location of the entry before and the entry after it.  So if one entry is added in the middle of million-item list, only two items have to be modified – saving valuable resources.

Instances

I followed up my time in lists with a brief overview of instances, basically like a blueprint of shared methods for classes.  I worked a few examples over the weekend, though I personally have yet to grasp the benefit of implementing instances on my projects.  But I am sure I will see them down the road as I progress through my Java course.

You may also like