Find online courses made by experts from around the world.
Take your courses with you and learn anywhere, anytime.
Learn and practice real-world skills and achieve your goals.
Learn about programming through a series of short, concise examples with line by line explanations covering everything from getting up and running to object oriented programming, data structures, and various tips and tricks to help you along your way.
Section 1 will get you up and running with everything you'll need to write and run Java programs.
Section 2 will introduce fundamental programming concepts such as variables, methods, and control structures that will put you well on your way to writing your own applications.
Section 3 dives a bit deeper as we learn about object oriented programming. You'll learn how to write code that can be reused easily, as well as gain some insight into technical details about how programs actually run on hardware.
Not for you? No problem.
30 day money back guarantee.
Learn on the go.
Desktop, iOS and Android.
Certificate of completion.
|Section 1: Getting Up and Running|
This tutorial guides you through everything you need to begin developing Java programs.
In this tutorial we create the standard "Hello, world!" application using Java.
|Section 2: The Basics.|
In this tutorial, we cover the basics of using variables in Java.
I use the word function interchangeably with method in this video (out of habit--methods in Java are called functions in other languages).
In this tutorial, I explain the basics of scope.
A variable declared outside of any method with the static keyword is called a class variable, and is available to all methods in the class (variables without the static keyword are called instance variables, and will be covered with object-oriented programming in future tutorials).
A variable that is declared inside of a method is local to that method, and only exists until that method is finished executing. It is not directly available to any other methods in the class.
This tutorial covers just about everything you'll need to know about if statements in Java.
There is another less common type of statement that allows similar functionality called the switch statement, and I will cover it briefly in a future tutorial when we have a practical use for it.
Sorry for the heavy edits. I wanted to get the time under YouTube's 15 minute limit so that I wouldn't have to break it into two parts.
In this tutorial we look at the three main types of loops in Java: the while loop, the do-while loop, and the for loop.
The debugger is also introduced. It allows us to see exactly how Java executes loops.
There is another form of the for loop that is shorthand for iterating over every element of a collection that will be covered in the future.
You can also achieve similar looping functionality using something called recursion, which will also be covered in the future.
|Section 3: Object Oriented Programming|
In this tutorial, I demonstrate how to instantiate and use objects by example. We use a JFrame object to create a window, and add a JLabel object to it.
You should probably add: window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // ensures program ends when we close window)
I also mention that Strings are actually objects (as a convenience, Java allows us to instantiate strings by using a string literal, that is, text in quotes).
You can use objects through what is called their interface, in other words, the methods that they make visible to us as users of the object. You can see all of the methods available via Eclipse's code assist feature by typing the object variable name followed by a "." (you can also bring up code assist by pressing ctrl + space).
In this tutorial we learn how to instantiate objects from classes that we create. We learn about instance variables, instance methods, and constructors. Getters and setters are introduced and encouraged as good coding practice.
The static modifier is also explained.
You would usually make instance variables private when public getters/setters are provided as part of the interface, but access modifiers have not yet been covered in this series.
You can also move the main method to the Person class and keep the program for this tutorial in one file, however, I thought it would better get the concept across by having the Person class be isolated from main.
In this tutorial we look at the difference between value types (primitives) and reference types (objects).
Primitives are passed by value, so when passed to a method, you aren't manipulating the original data, but a copy of that data.
Objects, on the other hand, are passed by reference, so you have the ability to change objects through that reference inside of methods.
In this tutorial, Java's access modifiers are explained. For now, public and private should make sense. Protected and default access are introduced, but won't be fully understood until packages and inheritance are covered.
As a best practice, I recommend using the private modifier as much as possible. This prevents users of your classes, which includes you, from manipulating the data for the class directly or calling methods that were only meant to be helper methods internal to the class. It will also decrease the number of things you can do with an object of that type as a user, so it makes it easier to learn or remember how to use it.
You should especially avoid making your variables directly accessible. The benefit of using methods to set values to your variables is that you can do error checking inside of those methods prior to the assigning the value. For example, it wouldn't make sense to try to set a Person's age to a negative value, so you can test to see if a negative value was passed to setAge() and handle it accordingly.
In this tutorial, we learn how to create and nest packages. We'll move all of our existing classes into a new package, and use this and other packages in the future to keep our classes organized.
I change to a hierarchical view for packages, but feel free to keep a flat view if you prefer.
I also show how using packages avoids naming conflicts by showing an example of using a fully qualified class name instead of an import.
The default and protected access modifiers are discussed briefly since they deal with package wide access.
In this tutorial I introduce data structures and we learn how to use one of the most basic structures, the array.
We look at different ways we can initialize an array, how to set values to array elements, how to get values from array elements, and how to iterate over an array using loops.
Be sure to remember that an array index starts at 0, so if you create an array of size 10, the indices will be 0-9. The last elements is always at the index size - 1.
This introduction is in no way comprehensive--there is much more to learn about arrays, but it should get you familiar with seeing and experimenting with arrays.
In this tutorial I explain how to make constants in Java by using the final modifier on variables.
By convention, constants are capitalized with words separated by underscores.
You usually want to make constants static because they typically do not change values across different instances. Using the static modifier also allows you to use the variable without creating any instances.
It is also generally safe to make your constants have public visibility, since applying the final modifier makes the variable read-only.
In this tutorial, I introduce a powerful feature of object-oriented programming: inheritance.
Inheritance allows you to have one class "inherit" the variables and methods of another. This help promotes code reuse, because common code is refactored to parent classes. It also helps keep your classes light weight and manageable.
All objects in Java extend the class Object. One thing I didn't touch on in this video is the notion of inheritance hierarchies. For example, even though our Child extends Parent, our parent still extends Object, so the full hierarchy is:
Object - Parent - Child
Thus Child "is-a" Parent, and also "is-a" Object.
In this tutorial, we continue learning about inheritance by covering overriding methods. Technically, overriding methods isn't specific to inheritance, but we will learn more about that after a couple more videos.
You can override inherited methods by creating a method with the same signature as one that is inherited (same name, return type, and parameters). Or you can use Eclipse's code assisting to do that for you, as I do in this video.
You can use the super keyword to reference the instance of the base class, and use it to call methods or access variables. This is useful for when you need to override a method to add additional functionality, rather than replace it entirely.
The @Override is called an annotation, is optional, and isn't important to learn about right now.
In this tutorial, we build on our understanding of inheritance by introducing abstract classes and abstract methods.
An abstract class is a class that exists purely to be extended. You can not create an instance of an abstract class.
An abstract class may have abstract methods. Abstract methods provide no implementation. They only provide the method signature (return type, name, and parameters). Any class that then extends the abstract class must provide an implementation for any abtract methods it inherits (unless that class is also abstract).
Another important note from this video is that the type of a variable determines the interface for the object it refers to (what you can do with it). For example, if we refer to Player by type GameObject, we are not able to call any methods specific to Player on that instance (unless we cast it to Player). This is something that we're likely to see more of in future tutorials.
Professional software engineer, hobbyist game developer, past Computer Science tutor, and occasional tutorial producer! That sounds more impressive than it is.
I've been coding in some form or another for as long as I've had a computer to do it on.
When I'm not doing that, I enjoy catching up on some shows, playing games online with some friends, and even occasionally going outside.