Java Object Tutorial – Part 2

We covered the basics in part 1 now lets see some other stuff that might confuse you.

You should focus on references because it is an essential part of Java and will greatly help if you try learning another object oriented language


  • References are pointers that point to some object
  • This can be a bit challenging for beginners but if you master this you are halfway done with java
  • Copy paste it and try running it, also delete the comments
  • I even created an image of how it looks in the background hope it helps



  • ArrayList is a container for objects, also called a data structure
  • You will see that ArrayList itself is a class and we need to initiaize it like Person to use it
  • It also comes with really useful methods like add, remove and contains

  • You maybe wandering, ok I put my objects into the list, but how do I get access to them again?
  • ArrayList has a get method to get an object from the list
  • But when you use the get method of ArrayList it will give you a reference/pointer to that object


Q : References/Pointers are hard to learn, do I really need to learn it?
A : I just cant stress enough how important it is for java so definitely YES, trust me it will be really rewarding in the future.

Q : Are there other containers/data structures like ArrayList?
A : Yes, but they are almost similar to ArrayList.

Q : Can my Person pointer like person1 point only Person objects?
A : Yes. Unless there is Inheritance involved, but leave Inheritance for later.

Q : When should I learn Inheritance, Generics, Comparable and other stuff?
A : You have to be really comfortable with plain java objects like in this tutorial. So complete this tutorial series and do lots of exercises. Example create your own class(es) and write similar code like in this part.

Recent Posts