• Google+
  • Twitter
  • YouTube
  • RSS
  • Facebook

Latest Java and Programming Tutorials

C++Tutorial for Beginners 46 – The New Operator; Allocating Memory in C++

coffeenews
The “new” operator in C++ allows us to allocate memory. This is the source of a lot of C++’s power; ……..

C++Tutorial for Beginners 45 – Copy Constructors; Creating Copies of Objects
C++Tutorial for Beginners 44 – Const; a Vital Tool for Reducing Bugs
C++Tutorial for Beginners 43 – References; Nicer than Pointers!
C++Tutorial for Beginners 42 – Reversing a String (Interview Question!)

You can now access ALL my premium courses for just $19 a month, cancellable anytime; no minimum period. Click here!

Free C++ video course: learn to program in C++ from scratch!

Java Spring Framework Tutorial

The Java Spring Framework Tutorial

My latest premium tutorial is an extensive introduction to the popular Spring Framework, including web programming with Spring MVC. $29.
My Kindle book about online teaching and my many attempts to free myself from office work … How to Make a Great Living Teaching Online

Java for Complete Beginners

Java for Complete Beginners

Completely free if you sign up via this link. Over 175,000 people have already joined this course on Udemy.com! Now available right here too. This course teaches you how to program in Java from scratch.
You can find lots more courses here

Want a Course but Can’t Afford to Pay?

If you want access to one of my paid courses but can’t afford to pay, email me at john@caveofprogramming.com with a brief email explaining your situation, and I’ll consider giving you free access.

Donate

If you feel like sending me some cash … well, thanks! You can do so right here:

Get a Job as a Software Developer

If you’re looking to get a job in software, my free Java for Complete Beginners is all you need, at the minimum. If you master the contents of this course and you’re prepared to travel and apply for lots of stuff, while there are no guarantees, you’ve got a good shot at getting a job as a programmer. This course includes advice about getting a job.

If you want to improve your chances by learning an advanced Java specialisation, my Servlets and JSPs (and JSTL) course gives you very marketable skills. You’ll need to separately study HTML and CSS a bit (not as hard as Java!) and preferably some SQL too.

Alternatively, you could Learn Android Programming or try Mastering Java Swing; Swing is widely taught in universities, but there are less jobs around for it than for web-based stuff (see Jobserve).

Finally, The Java Spring Tutorial gives you some very hot skills, but it’s advisable to learn about Servlets and JSPs first, unless you like being dropped in at the deep end.

My other free courses, Java Multi-threading and Java Design Patterns and Architecture, will certainly improve your chances in a job interview, and you can take them in whatever order you like.

{ 640 comments }

Leave a Comment

  • ashwin November 21, 2014, 12:10 pm

    can u please explain about vector list

    Reply
    • John November 21, 2014, 12:23 pm

      It is identical to ArrayList, except that it is synchronized. If you aren’t using multithreading, it’s better to use ArrayList if you can, since it doesn’t have the extra overhead of synchronization. Even if you are using multithreading, it’s probably better to do the synchronization yourself, or else use a more modern class like ArrayBlockingQueue. Vector has some issues … Sometimes you have to use Vector with older APIs, but then you just use it exactly like ArrayList.

      Reply
  • Chris November 18, 2014, 1:29 am

    can you please help me with something? I cannot for the life of my figure out why i can’t get this simple bit of code to work:
    import java.util.Scanner;

    public class AnchoviesApp {
    public static void main(String[] args) {

    //create scanner object
    Scanner Input = new Scanner(System.in);

    // output the promt
    System.out.println(“do you like anchovies? “);

    //wait for the user to enter a line of text
    String ans = Input.nextLine();

    String reply = null;
    if(ans == “Yes”){
    reply = “You are NOT a fool”;}

    if (ans == “no”) {
    reply = “You are a fool”;}

    System.out.println(reply);

    Reply
    • John November 18, 2014, 2:03 am

      Ahhh, the classic mistake of using == to compare strings, instead of .equals().

      Reply
      • Chris November 18, 2014, 5:45 am

        thanks! Someone else told me that and I tried…got error messages:

        Exception in thread “main” java.lang.Error: Unresolved compilation problems:
        Syntax error on token “if”, delete this token
        Cannot make a static reference to the non-static method equals(Object) from the type String
        Syntax error on token “if”, delete this token
        Cannot make a static reference to the non-static method equals(Object) from the type String

        at AnchoviesApp.main(AnchoviesApp.java:16)

        Reply
      • Chris November 18, 2014, 6:04 am

        correction, I was using the wrong variable…however, not this is only giving me “You are a fool” no matter what I give for an answer. Its the same problem as when i was using ==

        import java.util.Scanner;

        public class AnchoviesApp {
        public static void main(String[] args) {

        //create scanner object
        Scanner Input = new Scanner(System.in);

        // output the promt
        System.out.println(“do you like anchovies? “);

        //wait for the user to enter a line of text
        String ans = Input.nextLine();

        String reply = null;
        ans.equals(“Yes”); {
        reply = “You are NOT a fool”;}

        ans.equals(“No”); {
        reply = “You are a fool”;}

        System.out.println(reply);

        }

        }

        Reply
        • John November 18, 2014, 12:33 pm

          This is case-sensitive — maybe that’s the problem? You can transform the input to lowercase and compare it with a lower-case string;
          if(ans.toLowerCase().equals(“yes”)){

          }

          Input here should really have a lowercase “i”, input, since it’s a variable and not a class.

          Reply
          • Chris November 18, 2014, 1:28 pm

            strange, it is lower case in my script. I must have been sleep walking or something when i posted this. But even still, nothing changes when I switch out to lower case.

    • John November 18, 2014, 1:34 pm

      The following code works. You have to type yes or no in lower case. If you find it doesn’t work, make sure you’ve saved it, and you’re definitely running the right project. You can try doing a “clean” build from the project menu too, in case it’s got into a tangle (but this is unlikely).
      import java.util.Scanner;

      public class AnchoviesApp {

      public static void main(String[] args) {

      // create scanner object
      Scanner Input = new Scanner(System.in);

      // output the promt
      System.out.println(“do you like anchovies? “);

      // wait for the user to enter a line of text
      String ans = Input.nextLine();

      String reply = null;
      if (ans.equals(“yes”)) {
      reply = “You are NOT a fool”;
      }

      if (ans.equals(“no”)) {
      reply = “You are a fool”;
      }

      System.out.println(reply);
      }

      }

      Reply
      • Chris November 18, 2014, 7:12 pm

        does this script work on your machine? Its still the same thing over here…its as if there is only one reply option

        Reply
        • John November 18, 2014, 7:21 pm

          Yes, it works. Try putting in a sysout to display the text the user inputs.

          Reply
          • Chris November 18, 2014, 9:16 pm

            I re-wrote the script, same problem arises. By the way, I really appreciate your input on this. I know you must be very busy and have hundreds of people asking you elementary questions like this…anyway, my new script, with your suggestions, outputs the user input accurately, but still only gives me one answer no matter what…I could type anything and it will still give me the same output.

            import java.util.Scanner;

            public class Anchovies2app {
            public static void main(String[] args) {

            Scanner input = new Scanner(System.in);

            System.out.println(“Do you like anchovies?”);

            String ans = input.nextLine();

            String reply = null;

            ans.equals(“Yes”);
            reply = “You are not a fool”;

            ans.equals(“No”);
            reply = “You are a fool”;

            System.out.println(reply);
            System.out.println(ans);
            }
            }

          • John November 18, 2014, 9:46 pm

            No problem! This one has got “if” missing from it …

          • Chris November 18, 2014, 10:01 pm

            but “if” in front of “ans.equals(“Yes”); (and “No” for that matter) gives me error:
            Exception in thread “main” java.lang.Error: Unresolved compilation problems:
            Syntax error on token “if”, delete this token

          • John November 18, 2014, 10:03 pm

            You just need the right syntax. if(condition) { code }

            if(ans.equals(“yes”)) {
            reply = “something”;
            }

          • Chris November 18, 2014, 10:35 pm

            Still gives me the same problem. The first reply is ignored no matter what I answer with:

            import java.util.Scanner;

            public class AnchoviesApp {
            public static void main(String[] args) {

            //create scanner object
            Scanner input = new Scanner(System.in);

            // output the promt
            System.out.println(“do you like anchovies? “);

            //wait for the user to enter a line of text
            String ans = input.nextLine();

            String reply;

            if(ans.equals(“No”));
            reply = “You are a fool”;

            if(ans.equals(“Yes”));
            reply = (“You are NOT a fool”);

            System.out.println(reply);
            }

            }

          • John November 18, 2014, 11:11 pm

            You need to remove the semi-colons after the ifs. Not if(ans.equals(“No”)); but if(ans.equals(“No”))
            I don’t mind at all answering questions, but you’ll find it easier going if you first get the hang of ifs and loops and other stuff, in smaller programs. Otherwise it’s really hard to figure out where you went wrong. Although, I know that sometimes you can get the hang of this stuff, but then end up driving yourself crazy with some small mistakes.

          • Chris November 19, 2014, 12:15 am

            Bingo! Thanks so much for hanging in there with me to the end. I’ve been using your Java for Beginners course. Does this stuff ever get easy?!?!?! Thanks again!

          • John November 19, 2014, 12:31 am

            Yes, it does. It is just difficult at first. As I say, writing your program step-by-step, testing every step with sysouts, will help. But mainly it’s just a lot of practice. These two mistakes you made (== for comparing strings, semi-colon after an if or while) catch just about everyone at some point.

  • Zachary Orion Donnelly November 16, 2014, 9:52 pm

    This has helped me out so much i can now call my self a java programmer. So thanks i have created many games and i am the computer geek at my school just from java made me into a computer geek that know the computer inside and out. THANKS

    Reply
  • magdi November 15, 2014, 11:01 pm

    i wanna thank you john for your courses free and paid.
    and i wanna thank you as well for your generosity that you give some courses for free and giving the people who can’t afford the chance to get the courses for free, that means that you are an awesome and great man.
    at last i have something to submit, i need a compiler for java and need to know how to use it to get my program in java executive cause if i could not get my program executive i’ll never find a job as programmer like this

    and i wanna thank you again.
    your student

    Reply
    • John November 15, 2014, 11:07 pm

      Thanks for your kind words, Magdi. Do you mean you want to create a .exe for Windows? You can do this with JSmooth, which is free. It’s a little tricky to use, but there are lots of tutorials around if you search for them. You probably can’t create a true .exe, but JSmooth and similar tools can wrap a runnable jar and make it look like a .exe.

      Reply
      • John November 15, 2014, 11:09 pm

        There is also this, but I haven’t tried it … maybe it’s easier than JSmooth or maybe not. Either way, first step is to export a runnable jar from the File menu of Eclipse and get that working. http://devwizard.free.fr/html/en/JavaExe.html

        Reply
  • good work! November 10, 2014, 9:47 pm

    Your courses are awesome! Definitely looking for buying some advances courses later… It’s also good thing that you have given away very good video courses for free!

    Reply
  • Lana November 9, 2014, 7:37 pm

    Thank you so much, John, for putting this amazing course together and making it free!

    Reply
  • kutub uddin nezamy November 7, 2014, 7:47 am

    Hi jhon, l saw your java tutorial it is very fine.

    Reply
  • Dignity November 6, 2014, 10:17 pm

    Hi John
    I really appreciate your efforts..
    You are one in a million.
    God bless you

    Reply
  • Learner November 5, 2014, 1:12 pm

    Hello John,

    The way you explain is really easy to understand and reproduce.
    Your contribution towards java learns is really appreciable.
    My salute for your effort and time you spent on preparing these videos.

    What makes you awesome is you gave it for free. i believe this would have helped millions on people to learn java.

    Thanks Again
    Learner

    Reply
    • John November 5, 2014, 1:27 pm

      Thanks! I think not quite millions, but a lot, so I’m happy!

      Reply
  • Vincent Vinicenko November 5, 2014, 10:35 am

    Dearest John,

    Thank you ever so much for this free Java course, I am learning to read code at ridiculous speed and even though I must go through the course again to strengthen my knowledge – I am honored to hear your voice in my speakers the times I spent studying.

    I hope I can pay you back and shake your hand some time soon after getting my junior developer position.
    This is TRULY a ticket to life you are giving away to ladies and gents all over the planet FOR FREE!

    Warm wishes,
    Your student, Vinny.

    Reply
    • John November 5, 2014, 10:54 am

      Cheers Vinny! Great to hear. Good luck with finding a position. Let me know it goes.

      Reply
  • Nurlan Isazadeh November 4, 2014, 2:29 pm

    Hello,John.Your tutorials are very good.But about this website,I want to say that changing design a little bit would be very good.Because colors are old-fashioned,and my eyes got tired after couple of minutes.
    Regards

    Reply
  • Petar November 4, 2014, 12:58 pm

    Hi,
    First of all thank you for the great, free, Java tutorial. I am doing your begginers Java tutorial and my final goal is android applications development. My question is what would you recommend after this basic tutorial on java, should I go directly to the android tutorial or would it be better if I do something in between? Thanks again for the great tutorial, I have done other Java tutorials from Udemy, and from other sources, and I find this one is the most suitable for me.

    Best regards!

    Reply
    • John November 4, 2014, 1:58 pm

      Cheers Petar. When you’ve got through the beginners’ tutorial, you’re good to go with Android. You might want to learn some SQL too, but you can use my tutorial itself as a starting point and enlarge your knowledge as and when you need it.

      Reply
  • Maverick November 4, 2014, 4:49 am

    Hi John,

    Really liked your tutorial videos….very well presented.
    Can I request you to create such tutorials for webservices also.
    Webservices are desired skill sets and I did not find some really well explained stuff on the net.

    Reply
  • Thank You November 1, 2014, 12:32 pm

    Half way into your Java tutorials at udemy.com, I simply had to come here to say thanks for an amazing work you did. Love how you explain concepts in a simple way with no unnecessary talking (most books and courses have this problem, I think). Also love the fast pace, I am touching Java for the first time and do not want to get very technical yet and to memorize the actual syntax and how you write things. On the other hand, I feel I am getting familiar with what Java can and can not do very quickly, precisely what I have been looking for. Thank you so so much! Hope you keep putting more amazing content out there!

    Reply
  • furruq jahangir November 1, 2014, 12:59 am

    PERSONAL
    Hello there!
    Is your middle name Frank?
    Are you ex-SIDF?
    Regards

    Reply
    • John November 1, 2014, 8:59 am

      No, and no ….

      Reply
  • hyde niven October 31, 2014, 1:56 pm

    I subscribed to spring tutorials, and other java tutorials.I love to give 5 star ratings.Really great videos

    Reply
  • robert Dye October 30, 2014, 9:49 pm

    Hello Jon, Ive been following your tutorials on Java.
    A lot of them are somewhat easy to grasp after trying them a few times, however others are a bit more difficult and have been using other tutorials to help solidify what the meaning is.
    One issue with your tutorials i have is that you do speed through some, i try to write word for word what you write and then re-look at what I’ve done but a lot of the time you go really quickly and its hard to keep up without pausing the tutorial.
    For future tutorials, could you please slow it down a little, not everyone is fast at learning or typing and it would help a whole lot if your speed was reduced. Very much obliged.
    With your help, i will make a better life. So many thanks. Rob

    Reply
    • robert Dye October 30, 2014, 9:57 pm

      Oh and i forgot to add, Please don’t take this as a shout or rant or anything negative. But can you use other examples of class names rather than keep using machine, person, or plant etc as i have a few of those and many different variation as well from your other tutorials and from another person’s.
      I keep all tutorials in eclipse and i keep having to create my own classes and modify what your writing. (I know i should do that, but i do after the tutorial is done) But doing that while your teaching is hard and can get very confusing. Please use others like dog, cat, planet, whatever you like, just not machine, please. Very Much Appreciated. your tutorials are awesome by the way, thank you for your time

      Reply
      • John October 30, 2014, 10:56 pm

        :) Fair enough, I’ll at least think about it! I use Person a lot because it’s a realistic example and Person is a category. I suppose dog is a category too, but a little unrealistic to get into sub-categories of dogs in a program … Regarding speed, would you believe someone tried very hard to convince me recently that I needed to speed up a lot. There’s no really happy medium. People in favour of speeding up argue that you can pause or repeat a video, while those in favour of slowing down say that I lose them sometimes. I can at least try to avoid rapidly clicking between files and try to keep a measured pace ….

        Reply
  • mohamed Hamed October 29, 2014, 6:49 am

    I like the way you teach in details
    I will study your advanced java courses Servlets and JSPs (and JSTL)

    Reply
  • Nishul Tomar October 28, 2014, 8:19 am

    sir, i’m really a huge fan of ur video tutorials & i’m finding them very helpful in making my java concepts really solid
    i’ve send u a email @ ur email .i.d. requesting for accessing paid tutorials in free

    Reply