Java Object Tutorial – Part 0

This is a tutorial for complete beginners trying to understand Java objects and how they can be used.
The actual goal is to build up a way of thinking so that you can start developing and look for solutions on your own.

I will explain java objects like explaining something to someone in the street who has nothing to do with programming.

So when you read this tutorial, it will either make sense or none at all and definitely check Q&A at the end of each part.

Before we start

You can use any text editor.. actually windows users go download notepad++ or use eclipse(create a java project and name it something like JTutorial).

So when I say create a new class it actually means create a new file if using text editor or in eclipse create it through the menu.

ex: Create 2 classes App and Person translates to -> Create 2 files named and

Lets Start

  • Create 2 classes App and Person
  • App – This is the starting point of our java Application, without this our application can’t start
  • main – special method that starts the application
  • Person – class to be used in our application

Why and whats is Person

  • Person class represents a real person, so it could have been anything from real life like an auto, house, cigarettes and so on depends what your application is about
  • Since every person has a name, Person class has a field/attribute called name
  • Methods setName and getName are helpers to access the name of one person, so if you wanted to change the name of one person or ask his/her name you would use these methods


Q : Does every java Application start with the main method?
A : No. There are other types of java Applications which dont need a main method, but the way objects are used is completely the same.

Q : What does ‘this’ and ‘’ mean?
A : ‘this’ means the current object(more about objects in next part) and ‘’ means the current objects name.

Q : Do I always have to write set/get for all the fields of a class like Person?
A : No. Sometimes you can write only get methods if you are not going to change anything. But to keep it simple for now write them both.

Q : What does public/private mean?
A : They are access modifiers to the fields or methods. I’ll cover this in upcoming parts, but if you want to know and it is also good to go ahead and read about something you dont understand or want to know more.
Visit Java Access Control or google -> java public private.

Recent Posts