Android Tutorial 2017

As Java is an object-oriented programming language, you need to know what does it means and how to use it. In this Android Tutorial you will be learning the basic concepts that will help you developing classes and using them. Let’s learn the main concepts that will help you get inside the Android development’s role.

Full transcript


In this video I’m going to show you the main difference between an object, a class an attribute and a method with a simple example. The example that I’m going to use is the class human.

Let’s remember that a class is the definition of the behavior and characteristics of an object. So with this definition we are defining a simple class but a class as I already said, needs the definition of the characteristics of the object and the behavior or actions or methods that our class will or our object will do, so let’s start with the characteristics or attributes for our class human. A human can have many characteristics such as gender, name, birthdate, height, weight, and more many many more.

For this example we’re going to use only this attributes ok, just as a simple example. We can have other characteristics as the color of our eyes, the color of our hair, maybe how strong we are or how long is our hair or other things for this example we’re going to keep it simple ok, so this are the attributes.

How do you define them in our human class? in our class human we are going to use public class human. This is the class, let’s remember that and to define the attributes we are going to use the the data type, in this case we’re going to use char, string, date, double ok. We could use just one line for this it’s just an example ok, just a simple example of these attributes so this is the definition of our attributes of the characteristics that our class human has, that our object human or any instance of human will have, ok.

So our class human also has actions, methods or behavior as anyway we want to call it. In Java it’s called methods, in our daily life we can call it action or the behavior of our object. So we as human do many actions like speak , eat, maybe get older or celebrate our birthday, sleep, study, listen, drive, we can do many things anything that we can imagine.

We can use it, we can define it here in our class human for this example, for this class human example, i’m just making 2 methods in Java, over here, method “speak” and the method “listen”, ok.

What do we do when we speak? We just say a sequence of characters, ok. So what will our method receive? It will receive a string of words, a string called words and What will it do? it will print out the words, the words that the method received ok, so for our second method which is called “listen” we won´t print anything, we won’t return anything we will just listen and keep it in our memory. Ok, that could be another attribute, we have memory, ok and it will just save and save, strings or arrays or whatever we want ok, so for this example a variable that initially was null or empty will save the string words that was received. Ok, so these are the methods or actions that our class human is defining, so.

Objects, What could be an object? An object could be the human Connie, an object could be the human Isabel, as I am. The human object could be John, Betty, Alfred, James, Mary and How do we declare? or How do we show it to our program in Java? In our Main class we call, we make a new human which is called “Connie” and this this human “Connie” is a new object, is a new object that will have the all the characteristics that a human class defines. Our human Connie will have a gender will have a name a birthdate, a height a weight and everything that is defined in our class human. If we made all other if we define other attributes then this human Connie will have all these attributes with its own characteristics.

For example: Connie’s birthday will be January 22 of 1987 and John’s as I wrote over here John´s birthday will be December 8 of 1986. And Connie’s gender is female while John’s gender is male. And Connie’s name will be Connie Johnston while John´s name will be John Brown. Ok, so they have their own properties and the actions are the same but that parameter that will be called may be different or may be the same, ok.

So this is a short example of what´s the difference between object, attributes, methods and classes.