Java Video Tutorial 5

Java Video Tutorial 5Here I continue my Java Video Tutorial by covering methods, or functions in Java.

I spend a considerable amount of time on those things that tend to confuse people who are learning Java. I review how class variables differ from local variables and provide numerous examples of methods.

If you missed the first tutorial see Java Video Tutorial, since I use a lot of code here that I explained previously. To help you better understand this video, see the code below.

If you like videos like this, feel free to share them [nttfblike]

Code From the Video

Java Videos in the Series

33 thoughts on “Java Video Tutorial 5”

  1. Thank You for gave us wonderful tutorial of JAVA…
    when will you upload next tutorial video on this site?

  2. i just loved ur tutorials…they r great…but i hav a que too…m not getting the concept of ‘static’…with varibles , method , and main method…

    1. I think you may have asked this question on youtube, but either way I hope this helps. If not tell me and I’ll explain it further.

      Static fields are tied to the class and not the objects that areο»Ώ created by a class. No matter how many objects you create there will only ever be one value for that static field. Static fields are normally constants or are used for tracking. Static methods are used to perform 1 operation. Like Math.random() is used to generate a random number. Static fields can’t be declared in main, or any method because they are class fields. Does that help?

      1. Your definition of static is awesome..it added a lot of meaning to my knowledge of static…I now understand what static is!

  3. and what if i declare the input varibale inside the main method…and if declare any varibale as ‘static’ but inside the main method..then would it not be accessible to other classes???

  4. hei Derek,
    i need to thank u a lot. .i hate programg languages,but ur videos made me to love it. .tey r super duper easy to learn things tat too,in a easier way. . kep ur work going. .

  5. *****************************************
    public class Testing
    {
    private int speed = 10;

    public static void testing (String[] args)
    {
    int speed_local = opening(); // this is not letting me go to the method
    }
    private int opening()
    {
    int s = speed;
    return(s);
    }
    }
    ************************************
    why can’t i go reference a non static method from a static one? how would i be able to access my private speed

  6. Hi, Derek. I need your help. Please explain!

    WHAT IS THE MEANING FOR THE UNDER BELOW DESCRIPTION???
    WHAT IS RETURN -1 stand for???

    if(guess == randomNumber)
    {
    return -1;
    } else {
    return guess; }

    1. checkGuess() is checking if the guess and the randomNumber are equal. If they are it returns a -1 which ends the while loop. If anything other then -1 are returned the while loop continues to ask the user to guess again. Does that help?

    1. When I was growing up my Great Grandmother believed that when you do bad things that they will eventually come back to haunt you. The same was true if you did good things. She referred to this as Karma, but she also considered herself to be a Christian.

      I personally always try to follow this belief. I have read many religious texts, but I was also taught as a boy that the only rule we need to follow to be happy is to do to others what we would have them do to us. I think that has worked pretty good for me because I’m very happy today.

  7. Hi Derek,
    Thank you, greats tutorials, i love them.
    Could you please post some exercises based on your tutorials so we can practice.

    1. Hi Eran,

      Thank you πŸ™‚ I’ll see what I can do in the future. I plan on making free Android apps that will go along with these tutorials to help people practice. That is the major goal for this year.

  8. Hi Derek. I’m new to learning Java. I’ve watched this video for like 4 or 5 times until I understand what is going on. Great video! I hope I can teach others about Java just like you someday. Besides Java, I can feel that there is something which stirs my heart in your video and this website. Perhaps it’s called passion. I appreciate it. You’ve made my world a bit more beautiful.

  9. Derek, Thank you for taking the time to be so thorough and thoughtful in your videos, comments and explanations.

    When first undertaking the job of learning java, I thought it would be mere weeks to understand the concepts of the language. Not so, at least, for myself.

    I have subscribed to various services and viewed hundreds of videos to determine that this will be a long-term learning process.

    Upon discovering your tutorials my learning has markedly improved and I actually enjoy and look forward to your lessons. I can not say “Thank You” enough times for the difference you have made.

    May the Lord bless you and your family.

    Thank You,
    Nick

    1. Hi Nick, Thank you for the nice compliments. Yes there is a lot to learn to be a great programmer, but it is doable. Everyone eventually has a aha moment when everything starts to make sense. Mine came when I started studying object oriented design. Everything made sense then. I have a OOD tutorial here. Learning UML may help greatly as well. May God bless you as well πŸ™‚

Leave a Reply

Your email address will not be published. Required fields are marked *