Introduction to Java Programming for Online Learners
3.8 (213 ratings)
Course Ratings are calculated from individual students’ ratings and a variety of other signals, like age of rating and reliability, to ensure that they reflect course quality fairly and accurately.
2,156 students enrolled

Introduction to Java Programming for Online Learners

Supplemental instruction on java concepts found in online programming courses, designed to help students truly learn.
3.8 (213 ratings)
Course Ratings are calculated from individual students’ ratings and a variety of other signals, like age of rating and reliability, to ensure that they reflect course quality fairly and accurately.
2,156 students enrolled
Created by Brian Gorman
Last updated 1/2018
Current price: $139.99 Original price: $199.99 Discount: 30% off
5 hours left at this price!
30-Day Money-Back Guarantee
This course includes
  • 23 hours on-demand video
  • 14 articles
  • 56 downloadable resources
  • Full lifetime access
  • Access on mobile and TV
  • Certificate of Completion
Training 5 or more people?

Get your team access to 4,000+ top Udemy courses anytime, anywhere.

Try Udemy for Business
What you'll learn
  • Introduce the student to Java
  • Build solid Java programming skills for anyone wanting to learn the language
  • Aid online students taking self-directed courses, or courses with minimal instructor interaction
  • Challenge the student to work with the code and engage in the material
Course content
Expand all 135 lectures 22:56:17
+ Introduction to Programming
14 lectures 01:22:03
This lecture is our course overview, talks about who I am as your instructor, some of my experiences and ultimately gives a guide on how to proceed through each week/section of the course.  Additionally, the topics covered in the course are exposed so that everyone can easily see the information that will be discussed in our course.
Preview 04:42
This lecture is a quick introduction to programming.  Essentially, we all want to get out of the gates and run as fast as possible.  This introduction discusses some of the pitfalls with that approach.  In the end, we need to commit to ourselves and give ourselves the time required to work through the material in a way that helps us to master it through each section.  Learning to program is an investment, and like all investments, will take commitment in the form of time and effort.  Here we go!
Preview 12:27

In order to work with Java, we need to have the SDK up and running on our machine.  This video is the me installing the latest version (jdk 9.0.4) at the time of this recording.  We could probably get by with Eclipse without the JDK as long as we have a JRE, but eventually you might get to the point where you need the JDK for some Java development, so I've always just installed 

This video takes us through the installation of the Java 8 SE SDK on our Windows 7 Machine. Please note that all code samples and examples also work with Java 6/7/8/9, so if you are installing Java for the first time, you should use the latest version of the Java 9 SDK. No matter what, your directory structure will be slightly different to reflect the version you installed, but it should not cause you any issues with the code. Whichever version you use, please make sure to continually update your version as prompted to maintain the best level of security with the Java installation.

Preview 05:13

This video walks us through setting up our windows machine to compile and run a program. For this video, you'll want to get the file "" and make sure to place it somewhere on your computer that is easy to access, such as the desktop.

Make sure to follow along with me in the video to complete the steps for manual programming, which make sure we are ready to go for writing java programs on our machine.

Preview 04:59

This video shows us how to write our very first program, the standard "Hello World" text printing program. Although we haven't covered syntax to this point, the program is simple and straight-forward.

To maximize your learning from this course, I highly recommend that follow along and perform all of the actions which I am performing in the demonstration. This will help you to learn the material, understand what is truly going on, make mistakes from which you can learn, and ultimately retain the knowledge from these instructional videos.

Although we will have a working file 'HelloWorld.' by the end of this lesson, I am not including the file for download on purpose. This will encourage you to create the file on your own. Additionally, if you have any mistakes, you'll have to fix them. Hopefully you will find this a simple and useful activity.

Please note: If you are using the Java 7 SDK, you will need to select the default folder installation path for the Java 7 version you are on, instead of java 6. Use that path when working with the environment and/or manual programming to execute the javac compiler and java runtime executable programs.

Preview 08:21

In this video, we take a moment to purposefully break our helloworld program, thereby giving us the opportunity to see errors as they happen at compile time, and learn how we might respond to the errors. This demonstration also shows us how programming manually can be more complicated than programming with an IDE due to the feedback not happening as quickly when we make an error.

By purposefully breaking our code, we get used to seeing some errors that we might encounter later. The experience of having broken the code and seeing the direct result may help us to fix errors later when we encounter similar messages from the compiler.

Please note: You will need to select the default folder installation path for the Java version you are on, including the correct current update number . Use that path when working with the environment and/or manual programming to execute the javac compiler and java runtime executable programs.

Preview 05:46

This video shows a demonstration of installing the Eclipse IDE (which you may choose to use for the remainder of our course; new videos I produce will use this IDE going forward as I no longer use Netbeans - however every java program we write in this course can be done in any Java IDE, including both Netbeans and Eclipse).

Preview 06:09

This video shows a demonstration of installing the Netbeans IDE (which you may choose to use for the remainder of our course; old videos use this IDE, new will not).

After installation, we'll quickly create a HelloWorld project to make sure everything is working and see how a powerful IDE can be beneficial to any programmer.

Preview 04:59

This video shows how to quickly create a project in either NetBeans or Eclipse. Going forward, the lecture resources [files] will be available as *.java files. Therefore, you'll be creating your own project and just importing the resource files.

The files attached for this video are actually going to be used in the next video as well, so this will give you a head start on setting up your project for the next video, and will highlight the idea of creating your own project to work along-side of me as we go through the lectures together.

Preview 03:39
In this video, we cover some of the basic syntax for writing programs.  In the getting started exercises we've already seen some of this syntax, however in this lecture we take a deeper look at what is required to make sure a program will compile, as well as learn a bit more about what is required to make a program run.
Preview 12:13
This lecture is a brief overview of printing output to the screen using three different types of printing.  The first type is the println("..."), which we've already seen.  The second type introduces printf -- or formatted printing, and the final type introduces the basic print statement.  Most of our code will use either println or printf, but it is good to know about the print statement as well.  Additionally, we take a quick look at using variables, by introducing the String type and setting a variable using Strings.  We'll cover variables in more details in Section 2, so this brief introduction gives us a taste of what is to come.
Preview 06:31
This video gives us a "real-world" printing example.  Additionally, the second part of this video dives into a bit more advanced printing options, introducing String.format and gives us a chance to recognize some patterns to make a better printing procedure.
Preview 07:00

All of the code for section 1 is contained here. Additionally, you should find the required code for each individual lesson attached with the specific lesson.

Sample Code for Section 1
1 page

Quiz for the material in section 1

Section 1 Quiz
10 questions
+ Programming With Variables
11 lectures 01:00:29
This video introduces us to types in Java.  The concept of a type is discussed, and the main types we are going to use are described, with some computer science behind some of the numbers.  The types covered and introduced are Integer (int), Long (long), Float (float), Double (double), Character (char), String, and Boolean (boolean).

This video is done on a lecture whiteboard, which can be difficult to write on at times so some of the handwriting may be a bit tricky to read.

Introduction to Types - Part 1: Number Types

This video is the first of two parts to discuss storing types in variables and working with the types in code.

In this video, we go over the Number types of Integer [int], Long [long], Float [float], and Double [double].

Storing Types in Variables - Part 1: Number Types

This is the second part of our introduction to types. In this lecture, we discuss the non-number types of Character [char], String [String], and Boolean [boolean].

Introduction To Types - Part 2: Non-Number Types

In this video, we continue with coding examples for storing and using types in variables. This video focuses on the non-number types of Character [char], String [String], and Boolean [boolean].

Storing Types as Variables - Part 2: Non-number Types

This video starts our look at a couple of different methods for gathering input from the user. The first method involves using the java.util.Scanner, which makes it necessary for us to import the java.util.Scanner or java.util.* package. This video focuses on the use of the Scanner, and we'll mostly use the Scanner object in our course.

Simple Input using the Scanner

In this video, we take a look at another way to gather input - using the BufferedReader object.

Simple Input using the Buffered Reader
In this video, we take our skills to the next level, using variables to store user input as types and then performing mathematical calculations with the variables.  We then print the resulting calculations back to the screen.  
In the second part of the video, we take our first stab at using the documentation to learn about a pre-built library, the Math class.  Using the Math class, we have the ability to perform some common math functions for easily performing calculations without having to write these methods ourselves.
Working With Variables and Math!
This program takes what we have learned so far and starts to wrap it all together.  Because we are still somewhat limited in our knowledge, we have to write each calculator as a separate program   In the future, we'll be able to take more advanced skills and write a better version of this program that is more user-friendly and has the ability to allow us to choose which calculation(s) we want to run.

If you are taking a course and have an assignment due that does a simple input - calculate - output type of operation, this is a good place to stop and complete the program.  If you need to take user input and make decisions or change the calculation algorithm based on the user input, you should continue on to week 3 (section 3) to gain knowledge of decision statements and loops.

PIAT: Simple Physics Calculators

In this final video for section two, we do another exercise in gathering user input as well as handling the input by storing it in a variable and then ultimately placing the information into the correct location in the Sudoku grid. Finally, we print out the grid with the user input correctly placed in the grid.

As stated in the video, the game is not playable at this point, nor is it intended to be. We are still learning from the ground up, and positioning ourselves to be able to build the game in a way that it can be played later.

The more we repeat these activities, the better we get at them, so practicing different exercises like this is a really good way to enhance our learning, even though it's just a short and seemingly trivial activity.

Sudoku 2: Gathering game conditions and input from the user
This lecture is just the placeholder to contain the code used during section 2.  Please download the code and use to enhance your learning for this week.
Sample Code for Section 2

This quiz contains questions relating to the section 2 material.

Section 2 Quiz
10 questions
Section Two Resources
+ Control Statements and Methods
10 lectures 01:45:39
This video introduces us to boolean logic.  The discussion relates the use of true/false statements and shows how certain mathematical comparisons can be used, as well as boolean variables to determine if specific code blocks should be executed.  The introduction also discusses the 'And' and 'Or' operators and closes with a brief introduction to the syntax of the if .. else condition control statement block.
Preview 11:23
This video gives us our first solid look at using conditional control statements to execute certain code paths.  By setting variables equal to a certain number, we can determine if certain code should execute based on the value of that number and how it is evaluated in boolean statements, such as less than, greater than, and equal to.
Preview 12:24
This lecture takes us deeper into control statements, showing the ability to nest control statements inside other control statements.  Additionally, we take the time to look at using and and or operations to determine specific conditions that cause certain code algorithms to be executed.
Preview 15:52
This video is an advanced session.  While it is completely possible to code without the switch and/or without using ternary operators, taking a good look at these elegant code solutions now will help us to be more familiar with them when it is time to start building advanced, robust solutions.
Preview 10:03
This whiteboard lecture gives us a solid look at the structure of methods, and demystifies some of the reasons for typing certain aspects of the methods we have been typing.  The major parts of a method signature are identified and explained, and examples that we have already seen are used to help us relate to the idea of writing methods correctly.
Introduction to Methods
This lecture session gives us a solid look at some of the benefits of using methods.  For the first time in our coding to this point, we are able to separate some of the algorithms that are repeated or are easily isolated.  By placing these code blocks into methods, we are able to make our code easier to read and understand, but also position ourselves to have the ability to more easily maintain our code in the future.
Coding With Methods
In this lecture, we adapt the simple physics calculator from section two to make it more robust using methods.  In section two we had to have five separate programs, but in this section we can contain the entire code base for all five calculators in methods which are easily leveraged from one program.  We also adapt the speed calculator to work for any of the three variables being unknown.  As additional learning, a good idea would be for the student to take the code and adapt the other methods to work with unknown variables for a more robust physics calculator.
PIAT: Simple Physics Calculator with a Menu
This video is our weekly (section-ly) enhancement to the Sudoku program.  Here we implement methods to handle some of the gameplay functionality, separating building the board into smaller methods and handling user input in a gathering method that can be easily repeated.  Although we still don't have a working game at this point, we are getting closer with each iteration of the development cycle.
Sudoku 3: Checking input
Sample Code for Section 3

This quiz covers lecture material from section 3

Section 3 Quiz
7 questions
Section Three Resources
+ Loops - Repetitive User Input
11 lectures 02:25:27
Our first video this week discusses what a loop is, and gets us thinking about some practical examples of loops in our daily lives.  Additionally, the video talks about three critical aspects of all loops:

  1. Start Conditions
  2. Doing Something
  3. End Condition
The end of the video closes with a quick overview of what to expect for syntax when working with loops.

Looping - overview and syntax structure
This video discusses the first type of loop: the "while" loop.  Thinking about it, one could say something like "the loop will continue 'while' something is needed or something is going on.  This is how the while loop is set out.  Determine the starting condition (i.e. we need to gather input) and then while that condition is not met or is still going on, loop on the code algorithm, until the end condition is met (i.e. we have the correct input).  

This video shows two simple loops, which illustrate a couple of different ways to set up the loop.  Make sure to get the code at the end of the section to follow along and thoroughly read the comments in the code as we go.   Throughout the section we are going to learn a couple of subtle things about programming as we continue to study loops, and build our skills as java programmers.
While loops
This video presents similar information to the while loop video, however it demonstrates the use of the do...while loop in code.  The key difference from a regular while loop is the fact that do...while loops will execute at least once, no matter what, whereas a while loop may have a case where it never executes. This is due to the fact that the while loop evaluates the condition and then iterates, and the do..while loop iterates and then evaluates the condition to see if another iteration is needed.
Do...While Loops
This video demonstrates the for loop, which is the last of the three most common loops we'll encounter.  Although the for loop may seem a little tricky at first, it is actually very common and will become easy to use with practice.  The best part about the for loop is everything is declared in one line of code for all of the three important aspects of loops.
For loops
This video reviews what we've learned so far by implementing validation on user input by setting up loops to check for bad input and continue until good input is received.
Review and Practical Example: Preventing Bad User Input with Loops
This video presents an advanced topic: Recursion.  When starting out as a programmer, most likely you will not need to know how to do this, and most likely it will be a bit too difficult to just understand right away.  However, recursion is an important component to programming in intermediate and advanced courses and work, so it is good to know about this topic and see it in action.

Recursion is shown in this video using the Fibonacci sequence, which is one of the most famous sequences.  

Advanced Topic: Recursion and The Fibonacci Sequence
Our first PIAT lecture this section puts the information we've learned this week into action by upgrading our simple physics calculator.

This week we enhance the density calculations, adding both the ability to validate user input and also the ability to take any of the three density variables as an unknown and solve the equation accordingly.  Additionally, all user input in the main algorithm is validated.

The challenge at the end of this lesson is to be able to finish off the rest of the calculators to prevent invalid input as well as to be able to take one of the variables as an unknown and calculate the equation accordingly.

PIAT: Simple Physics Cacluator with Menus and Repetitive User Input
Our sudoku program this week continues to build on our Sudoku game.  Although we will still be left wanting for a better game at the end of this lesson, the progress we are making is markedly displayed by the ability to alter some of the things we are doing in our code and seeing it all start to come together.  We'll still only have the one puzzle in place, but by the end of this lesson we can at least loop for user input until it is completed, and validate user input along the way.  Additionally, we discuss a couple of problems the program still has and note them as features for upcoming versions.

Lastly, as it is important to create a quick exit from the looping for our demonstration, we get to see our first Easter Egg programmed into our code, which allows us to know a "cheat code" to quickly and accurately solve the puzzle!

Sudoku 4: Validated input, Repetitive input, Solve entire Grid.
It's time to take a step back and think.  This video discusses the complexity of our programs and how they are getting more complex each section.  Taking the time to plan before we program can be a critical timesaver, both in accomplishing the overall goal of the program and also by helping us to plan for traps such as bad user input, or special cases our program must handle. 

In this lesson, we spend time planning the things we need to handle in order to build code to keep score during the card game 500.  Special care is taken to validate input to gather the correct bid information and calculate the overall score for both teams after each round (iteration).

Software Engineering Time out: Plan before you Program!
Our last video this week is the implementation of the scorekeeper for the card game 500.  This final program puts everything together from the week, as well as shows how planning before we program allows us to easily envision where we might have loops, if statements, traps such as bad user input, validation routines, and/or calculations to consider, either in the positive or negative direction.

Seeing it all come together in this simple, yet robust program, is a good way to close off the section and demonstrate our clear understanding of looping structures.

PIAT Advanced: Scorekeeper for 500 [a card game]
Sample code for week four.
Sample Code for Section 4

This quiz tests knowledge on topics from section 4

Section 4 Quiz
8 questions
+ Basic data structures (Arrays)
9 lectures 01:32:37
This first lecture of section five gives an overview and introduction to arrays.  The type is described, and an example is discussed.  Additionally, the syntax and common uses are shown in writing as we talk about how we would code for an array.
Introduction to Arrays
This lecture is the first encounter with arrays in actual code.  Here, we take the knowledge we gained during the discussion in our previous lecture and apply it in code, building a couple of arrays, discussing common coding mistakes that programmers need to avoid, and seeing how to set values in the arrays, iterate the arrays, and get values from the arrays at each index or specific individual indexes.
Coding With Arrays

This lecture is our first real computer science discussion, as we take a solid look at the difference between how regular variables are only copied and used in multiple places of memory, thereby not being prone to referencing errors, while complex objects such as arrays (and classes next section) are referenced directly in memory.  The by value types (ints, booleans, Strings) don't get changed in methods when they are passed to a method, however the by-reference types are just a memory pointer, which means the same object is "referenced" and therefore, the changes made to a referenced object in a method actually affect the object that was created in the calling method as well as the object inside of the called method.

As an update to this, I want to point out that there is actually no such thing as "Passing variables by Reference" in Java. In fact, everything is passed "By Value." What actually happens is the variables for complex types are passed as By Value pointers that point to the address in memory of the complex types. This is why we see some behavior where complex objects are modified when the variables are passed to a method. For more information on this, please see this video that I did for O'Reilly:

Passing variables to methods in Java
This lecture is a quick discussion of a new looping type: the enhanced for loop.  Essentially, for object collections and arrays, the Java programmers have given us a very quick and easy method to access each item in the collection or array.  Since the length is pre-determined, the code is capable of iterating based on a "for...each" type of syntax.  This is a short lecture, so don't skip it.
Enhanced For Loop
In an earlier lecture, we discussed the perils of passing an array to a method and the problems that could result from the method changing that array (by reference).  Additionally, array size is 'immutable,' which means that we can't change an array size without creating a new array.  This often results in the need for copying the array in order to "expand it."  Therefore, we examine the perils of directly copying an array, setting up a referencing issue, and then how to make sure our arrays are not referencing one another when doing a copy operation, using the .clone() method and Arrays.copy().
Making Copies of Arrays
Another common issue with any data is that it needs to be sorted.  Additionally, there are always multiple ways to go about anything in programming.  In this lecture, we examine a sorting algorithm called "insertion sort" and use it to manually sort our array.  It's always a good idea to know how to do things ourselves, in case we need to do some custom actions.  However, when doing a simple sort, it is easier and safer to leverage built-in functionality.  Java has provided us a method in the Arrays static class, which is Arrays.sort().  The second half of this lecture shows how to easily leverage this method to sort our array.
Sorting Arrays
This "Putting it all Together" lecture is a bit longer than I had intended it to be.  However, to this point we hit the basics of working with arrays.  In this lecture, we start trying to classify a group of Federation ships, their name, designation, class, and commander.  Using this information, we are able to thoroughly discuss some of the perils and traps that we fall into when using arrays in our code.  There are options that seem to be right, but this lecture helps us examine why they are not the best way to do things.  Additionally, the last part of this lecture shows us an advanced topic: Splitting Strings.  There are two methods to split a string, and this method is the easier method to understand but the more difficult one to use.  When a String contains a delimiter, we can easily split the terms back into an Array of String objects.  This is how we determine the best way to work with our data is to create a concatenated string with a pipe delimiter, and put that entire String into one index in the array, allowing for sorting and guaranteeing that our record data is not accidentally mixed up.
PIAT: Star Trek Spaceships
Our week five take on Sudoku allows us to remove over 1200 lines of code from the game!  Now that we have a structure that can store out data (a Multi-Dimensional 2-D array), we can actually do a lot of the work via iteration.  We can use the .clone() method to quickly reset our game to the solved condition, and now we can remove all of the string references to individual slots (i..e zeroZero, zeroOne, zeroTwo) and can directly reference any slot in the grid by its row and column coordinate.  Two challenges not covered in this lecture that you could do for practice include writing a quick method that checks an entire row or an entire column to see if any numbers are repeated.  If the number is repeated, notify the user that their input is invalid.  If not repeated, allow the input.  The other challenge you use to test yourself would be to create a method to print each individual line as a single string and store each of these lines of data in a single-dimension String array.  The String could be pipe-delimited for every number, or you could get even more advanced and do a nested delimiter operation, where you first Split on "|" and then Split each of those results on ":".
Sudoku 5: Using arrays in the Sudoku Program for Grid Values and Solution Values
Use this link to download all of the sample code for week 5.
Sample Code for Section 5

This quiz is tests knowledge on topics from section 5

Section 5 Quiz
9 questions
+ Object Classes and Basic Inheritance
18 lectures 02:21:42

In this video, we're going to start from the ground up to examine what it takes to work with our own custom classes in Java.

I will be doing Unit Testing as we go, even though we haven't covered that just yet.  If you want to watch the JUnit section to get a better idea of what is going on, you are welcome to do so, but we're going to move through everything from the ground up, so you should be able to work along with me through the section.

I will encourage you to not just watch the videos, but to actually work them with me.  If you need to pause the video and come back, don't be afraid to do it!  As each video in this section will build on the previous video, make sure you are good with the material before moving on to the next.

Getting a new project setup to begin our study of classes

In this video, we begin our look at custom classes by creating our class Vehicle and looking at the implicit default constructor that comes as part of the class.

We also setup unit testing to make sure that we can test our Vehicle class.

Creating custom classes and working with constructors - Default Constructor

In this video, we begin our look at using properties in our custom classes.

Properties are also called "getters and setters" or, more officially, "mutators and accessors"

We need to have the properties in order to work with the object to set values for things like the "VIN, make, model, mileage, and year"

Working with properties in our custom classes - part 1

In this video, we continue our look at the properties for our custom class, and finish up all the properties and testing on our Vehicle class.

Working with properties in our custom classes - part 2

In this video, we take a look at creating the explicit constructor for our vehicle class.  The nice thing about the explicit constructor is that we can actually create and pass state to the object at the same time.  We also need to test for this, of course.

Creating custom classes and working with constructors - Explicit Constructor

In addition to constructors and properties, we also often need to work with custom methods in our classes.  In this video, we go over what it takes to write some custom methods and then test to validate they are working as expected.

Working with other methods in our custom classes

In this video, we begin a two-part  lecture on what inheritance is, how we use it, and why it is a powerful tool in object-oriented programming.

Introduction to inheritance - part 1

In this video, we conclude our two-part look at inheritance.

Introduction to inheritance - part 2

In this video, we begin working with inheritance by adding classes for Car and Truck that will eventually directly inherit from the Vehicle class using the "extends" keyword.  For now, we put them in as their own classes to see what it would be like without inheritance.

Adding the car and truck classes

In this video, we just take a final look at what it would be like if we didn't use inheritance in our system for the Vehicle, Truck, and Car classes.  We also look at how we have no ability to work with the code using 'polymorphism' -> which is the ability to treat objects of a common super type in a similar fashion, regardless of their underlying subtype.

The system without any inheritance

In the next two videos, we'll transform our system into a system that leverages inheritance.

We'll begin by making both the Car and Truck be a subclass to the superclass "Vehicle".  We'll do this by using the "extends" keyword, which is a critical keyword to understand class relationships.

Creating Subclasses using the extends keyword [part 1]

In this video, we complete our look at using the "extends" keyword to transform the Car and Truck into subclasses (or subtypes) of the superclass Vehicle (or supertype).  We also make sure all of our testing is in place and include the ability to work with unique properties on the Car and make sure that we can see how the inheritance changes our ability to program to all of the types using polymorphism

Creating Subclasses using the extends keyword [part 2]

In this video, we discuss what it means to "Override" a superclass method.  We'll override the 'toString()' method that exists on all objects in Java to make it more useful for what we would like to accomplish in our Vehicle system.

Overriding Base class methods

In this video, we discuss a strategy for testing the toString() methods for each of the classes, appropriately.

Testing the toString() methods

In this video, we take our first look at what it means to "overload" methods.  This is different than overriding, and it is critical to understand the differences between the two terms.

By overloading, we present methods with the same name but different parameter lists.  This gives us options as to how we would like to work with our object classes.

Overloading methods to create options
This lecture is our "Putting it all together" lecture, where we see another example of using the concepts we've learned during section six to improve upon our Star Trek ship management program.  
PIAT: Star Trek Ships By Class
This lecture wraps up our learning for section six by rebuilding the Sudoku program using classes to abstract different aspects of the program.  Because the generation algorithm for the puzzle is so complex, it is included in the program but we are not covering the techniques for generating a solution and pulling out numbers to create an active puzzle.  The code contains a link to the original article containing the source as well as briefly mentions the "dancing links" algorithm that is commonly used to generate solutions.  This week we complete the game's basic functionality, and now have a working game with validation and generation that allows for random puzzle generation and the ability to complete the Sudoku puzzle.  
Sudoku 6: Solver class

This is the code for section 6.

FYI - As of 2018.01.23 I've updated the videos.  The code is currently available on GitHub in releases.  I will be posting information about that as well as physical copies of the code soon.

Finally, if you start from the top and work down through lecture 70, you should not need any of my code, and working through it on your own would help you learn the concepts.  I get it that some of you might want to start in the middle, or validate your code against mine, which is why I'll post some physical copies soon.

Sample Code for Section 6

This quiz covers material from section six of the course.

Section 6 Quiz
9 questions
+ Abstract Classes and Interfaces
8 lectures 02:00:23
This lecture gives us our first look at interfaces.  Using a new system that contains vehicles, we are able to build an interface to define all of the common properties of vehicles, and then implement the interface in three classes, Car, Truck, and Motorcycle.  By using the interface, we are able to examine how the objects can be used together in the basic data structures of array and ArrayList, thereby examining our first look at polymorphism.
Introduction to Interfaces
This lecture introduces the concept of the abstract class.  One use of an abstract class can be to hold common information for all of the subclasses that inherit from the abstract class.  Like an interface, abstract classes cannot be instantiated, however objects that inherit from the abstract class can be instantiated to the abstract class type. This allows us to move all of the common Vehicle interface methods that had duplicated code in the Car, Truck, and Motorcycle into the abstract class.  Additionally, this lecture goes into some detail about implementing multiple interfaces or extending the abstract class and implementing additional interfaces.  We'll first move all of the common code for the subclasses into our common abstract class "VehicleBase" and then we'll add another interface called "FourWheelDrive" which we'll implement on the Truck object.  Finally, we show how to cast the object back to the correct type in order to get to the specific property of 'IsFourWheelDrive.' 
Introduction to Abstract Classes

This lecture begins our Putting It All Together lesson for section 7. For the first part, we'll build a class to manage vehicles as a system with the ability to find, add, and remove vehicles from the system. We'll also look at figuring out how to identify a few pitfalls and examine a few strategies to prevent the user from causing errors. For the system, we'll use the concept of polymorphism, and therefore the autolot will be coded to the interface, not to some specific type (for example, we only have one add method, not one for each type of vehicle, but one that handles all types of vehicles).

PIAT: Part 1: Autolot - Polymorphism and Writing code to the interface.

This lesson completes our examination of the autolot system. In part two, we build the driver (which is a console-based GUI) to interact with the autolot system. We discuss how this style of coding has helped us to build a system that allows us to reuse the Autolot code in other GUIs when we have learned how to work with them (such as websites).

PIAT: Part 2: Autolot - Polymorphism and writing code to the interface.

This lesson takes a look at the Starships that we were building in section 6. In this code, we learn how to implement the comparable interface so objects can be compared (which allows for sorting). Additionally, we discuss overriding the equals() method so we can easily call to the .equals() method to compare objects for equality.

Further Study: Implementing the Comparable interface and Overriding Equals

This lecture covers an advanced topic -- the Strategy Design Pattern. This is a simple introduction, but gives us a new idea to consider when coding: Coding a behavior. To this point, everything we've coded has been a tangible object. By coding behaviors, we can interchange behaviors in our code without having to write separate classes. We dive into this and build two behavior interfaces, one for propulsion and one for weaponry, then we implement three propulsion behaviors and two weaponry behaviors.

Please note that if you are taking your first course as a programmer this topic will probably be beyond the scope of the course you are taking. I am assuming, however, that most all of you taking this course will be continuing on to harder courses as well as pursuing programming as a career. Therefore, you will most likely encounter this idea in the future. If you don't need it for your current course, keep it in the back of your mind, because it will be good to know, even if you never need it for a course.

Programming with the Strategy Pattern: Creating classes to represent behavior.

The final lecture for section seven makes a couple of critical changes to the Sudoku program. The overall algorithm for the code and gameplay is not changed, however we add in a system called GameSystem that will ultimately allow us to have 10 games, with Sudoku being one of them. We create an interface for Game and implement a GameShell abstract class to handle the common code. Sudoku extends GameShell which makes it also a Game by default.

In this lecture we also create a player object to track common properties for players of all the games in the game system.

We then change the Sudoku code to no longer reference the main method and ultimately implement the code in the play() method, as well as to have one player object to track the Sudoku player.

Sudoku 7: Abstracting Player And Game Behaviors

Please find the code for section 7 attached.

Sample Code for Section 7
+ Testing with JUnit
14 lectures 01:58:37

This video is the first part of two parts of an introduction to testing. In this part, we go over some of the major arguments against testing and talk about how testing is actually very important, even if there is a bit more work up front.

Introduction to Unit Testing - Part 1

In this video, we conclude our introduction to testing by discussing some testing strategies and the unit testing methodologies. We also look at the different assertions and how we'll use assertions to pass or fail the unit tests.

Introduction to Unit Testing - Part 2

In this video, we go over creation of the unit tests in Eclipse and start our Person object and testing on the Person object, working from the ground up. After we get the test class and JUnit libraries in place, we begin our testing by testing the Person class constructors.

There are two sets of files for this video. The starter pack and the finished code. I highly recommend starting with the starter pack and working along with me. If you get stuck, there are some text files that contain finished versions of the code in both projects. If you are pressed for time and just want to review, or if you have completed the video and want to check your work, take a look at the finished version to compare results or see the end result of this part of the project.

Creating the Tests and Writing Tests for the Constructors

In this video, we continue our look at testing by adding the tests and then coding the accessors (getters) and mutators (setters) for our Person class instance variables.

As before, there are two sets of files for this part of the project. I again recommend using the starter pack and working along with me. The finished version is there for your convenience as well.

Testing Mutators and Accessors; finish Constructor Testing

In this video, we continue testing our Person object by writing the tests to verify the toString() method is working as expected.

We'll just verify toString() contains our expected property values using the contains method of the String class. If you need to do more thorough testing, like validating a specific format, you could do that here as well.

As before, there are two sets of files for this part of the project. I again recommend using the starter pack and working along with me. The finished version is there for your convenience as well.

Testing the Person toString() method

In this video, we start our examination of how we'll go about testing the Comparable interface, which will implement in the Person class. This method can sometimes be tricky to implement, so we'll take some time planning before we get started. Some good things to think about will be what inputs can be sent to the method, what specific values we want to return, and what the order of precedence will be for determining if one person is greater than, less than, or equal to another person.

Comparable is an important interface to implement when we are going to be ordering objects. It is very conceivable that an object like person would need to be ordered by last name, then first name, and sometimes we'll care about age as well. We take all three into account in this class.

Please find the planning spreadsheet and pdf/Word Document that I used attached to this video for your reference.

Planning testing for implementation of the Comparable interface

In this video, we go over the implementation of the Comparable interface and take the time to work through some of the testing. The amount of testing needed would go far too long for the video, so a set of instructions exists that allows you to follow through with creating all the tests and learn more about the TDD process.

As with the other testing sessions, I recommend getting the starter pack and working through to the end. The finished code is also available for you to review.

Testing the comparable interface

In this video, we take the time to discuss how the equals method works, and how we can override it and test it in our Person class. Once again, we'll benefit from our grid that helps us see which cases we really need to focus on for comparing to determine if two Person objects are equal.

Planning Testing for overriding equals()

In this video, we go over the coding and testing for overriding the equals() method in the person class. Once again, we use our plan to determine that all code paths are covered and that the method is working as expected with valid testing.

Testing the equals() methods

This lecture describes an advanced testing concept: abstract testing. In this lecture, we convert the Person class to an abstract class and then use that as a base class for three other class objects. We then show how we can leverage abstract testing using the factory design pattern to create a base test class that tests common function and is leveraged in the sub-test classes. This is an advanced concept which may not be needed as an introductory programmer, but I want to make sure everyone is aware that this possibility exists.

Abstract Testing

In this lecture, we create testing on our AutoLot system. We again use some abstract testing, however you could just continue to unit test each class individually if the abstract testing concept with the factory pattern is too complex at this time. The testing helps us to iron out a couple of bugs that existed in the AutoLot code, and is our first chance to see some real good testing where we have a full system that needs testing other than just basic class object testing.

PIAT: Autolot Testing

The final lecture for section 8 gives us the ability to see some testing in action in our Sudoku class. Some of the class is left untested due to the complex nature and the amount of time it would take to write the tests on the classes. Additionally, this is the only version of the testing where we leave the default Netbeans testing syntax in place (not using the extension of Junit and leaving the @Test directives in place in the code).

Sudoku 8: Adding Unit tests to our Sudoku Code
Sample Code for Section 8

This video is a quick overview of some of the differences between JUnit 3 and JUnit 4. The good news, you can keep doing everything you've done before in JUnit3 in JUnit 4 if you want to. In this video, we look at some of the differences between how the JUnit 4 syntax uses things like attributes while the JUnit3 syntax does not. Although the videos have not gone over exceptions at this point, one of the biggest differences is testing exceptions. Therefore, you may choose to work through Section 9 first, and then come back to watch this video once you are fully familiar with Exceptions.

EXTRA: J-Unit 3 syntax vs J-Unit 4 syntax
+ Exception Handling
8 lectures 01:35:20

Our first lecture in section nine is an introduction to exceptions. This introduction walks us through the different types of exceptions that exist and how we can leverage them in our code. We've seen many of the Runtime Exceptions already, and during this section we're going to learn how to write better code that keeps our programs from encountering 'hard faults' or 'hard stops' that occur when a runtime exception breaks our code. We'll also talk about Checked and Custom exceptions, take a good look at the try...catch...finally block, and look at how we might go about testing exceptions when they occur in code. Finally, a look at the hierarchy will show us how the Exception types are organized, which is critical when building proper try..catch blocks. All of the concepts presented in this introduction will be examined and explained in the lectures for section nine, so this is a great place to start when learning about exceptions, and may be a good reference to come back to as we become more familiar with exception types, try/catch/finally blocks, and testing exceptions.

Introduction to exceptions and basic error handling

Our first lecture with code dives into the subject of unchecked exceptions (runtime exceptions). Unchecked exceptions are Runtime Exceptions or extensions of the runtime exception class. During the lecture, we'll look at four of the most common runtime exceptions and develop code that causes these exceptions and use try..catch..finally blocks to prevent hard faults (or hard stops) in our programs. By the end of the lecture, we'll see how we can code to prevent runtime exceptions from causing our programs to break during execution, as well as start to understand how to recover from runtime exceptions and even being to dive into the hierarchical nature of the try..catch..finally blocks.

Unchecked Exceptions

Lecture three for section nine gives us our first look at Checked Exceptions. The main way we'll interact with Checked Exceptions in our course is through files -- which we'll talk about in Section 10. With that in mind, this is a quick look and shows how the compiler will act when Checked Exceptions are encountered. A critical difference is also pointed out for when to use throws vs. when to use throw.

Checked Exceptions

Lecture four for section nine shows how we can write our own Exception types that extend the RuntimeException object, and can be thrown and caught as needed. The second part of the lecture dives into how we go about testing the Exception object and also test the code that throws exceptions to make sure that Exceptions occur when they are supposed to.

Writing Custom Exceptions and Testing Exceptions

This lecture takes a look at how we test exceptions in JUnit 4. With the new syntax, we can easily tell the test method what exception to expect and allow for the testing of that specific exception.

The person class is modified to throw an IllegalArgumentException when an invalid age or name is encountered. The tests are set up to expect the exception to happen, first with valid code to fail the test and make sure the test does not succeed when good code is passed that does not throw an exception, then the line of code that causes the exception is added to make sure the exception is thrown as expected.

Remember not to put any code in the test after the line of code that causes the exception, because the JUnit 4 syntax prevents the code from executing once an exception is encountered.

UPDATE: Testing Exceptions in J-Unit 4

Our PIAT lecture for this section continues the AutoLot coding and uses exception handling, illegal argument exceptions, and a custom exception "MustRefuelException" to put all of the concepts together that we have learned about using exceptions during section nine. We'll see everything except the checked exceptions come into play in this system, including using try..catch...finally blocks, using a custom exception, using illegal arguments to prevent bad input, and testing to make sure that our exceptions are working as planned. We'll also use try..catch blocks and some crafty looping to make sure that user input is exactly correct in our "GUI" program (the Driver). Now that we have completed the learning on exception handling, our code is becoming much more robust.

PIAT: Autolot with Exception Handling

Our final lecture for section nine gives us yet another look at creating a custom exception type (the SudokuGridCellException) as well as using try..catch to handle exceptions, testing that exceptions happen as expected, and a final look at throwing new illegal argument exceptions when the user has provided invalid parameters to a method.

Sudoku 9: Adding Exceptions to prevent errors from breaking the program.
Sample Code for Section 9
+ Files, Serialization, and Streams
10 lectures 01:40:23

The first lecture of Section 10 gives us an introduction into working with files by showing how to read from files in a couple of different ways. Things to note are that there are multiple ways to work with the files and each works equally well. We also get to run into some of the checked exceptions that we didn't really see last week. Our first file readers just open a text file and read the test and print it out either with all capital letters or all small letters. The main ways to open and read files are illustrated through the use of the FileReader and BufferedReader object, as well as the File and Scanner objects, and the distinctive way each combination needs to work to access all the data correctly from the file.

Opening and Reading Files

Our second lecture this week dives into writing to text files. As with reading files, there are multiple ways to write to a file so we take a look at a couple of them. The first way we write to the file is with the FileWriter itself. The second way involves decorating the FileWriter with a BufferedWriter. The final way uses a Printwriter with a File object. All three methods to this point have been wiping out the file and re-creating it with the new output. The final demonstration for this lecture shows how we can append text to the end of an existing file.

Writing to files

In this video, we get to start putting everything we've learned this section to the test. We'll use file readers and writers to open a file and read the text. We'll then work with that text to perform a cipher-shift on each character and save the result to a text file. In this manner, we get to see a very simple encryption example that we could easily do with some file I/O. Unfortunately, this encryption is not at all secure, so we won't be using it to protect any sensitve information anytime soon.

Basic Secret Agent Encryptor and Decryptor (using File IO and basic Encryption)

In this video, we learn a bit about what Serialization is, and how to serialize our custom objects in java. We'll implement the Serializable interface on our custom code and then create a doctor object that we'll save to a file as a stream. Finally, we'll restore the doctor object from the stream and compare to see if it is equal to the original object.

Serialization of Objects to Binary, and Saving the serialized object to a file

This second look at an encryption program lets us use the fact that we now understand how to translate our object into a stream of bytes. By serializing the object and putting it into a stream, we are then able to easily change the data by performing a shift at the byte level. Once we do this, files become unreadable and even unusable in their native form in some cases (we've corrupted the file). We can easily get back to our original file by simply performing the decoding of the data by shifting each byte back to where it was. Here we show how to encrypt our text message file, and we also show how we can change a .jpg image into an unusable file that won't display as a picture until we decode it.

Improved Secret Agent Encryptor And Decryptor Program

For our final new topic on opening, reading, and writing to files, we take a look at Random Access Files. There are some critical points to note about Random Access Files. First, these files are binary, so they can save state. Second, they are the only type of file in Java that allows us to both read from and write to the file. They also provide the only mechanism for traversing through the file in any direction other than forward and in any order (hence: random access). The key idea is to determine the size of the data in the file and then use the file pointer to move to the next record location. It is then easy to pull data from that location or to overwrite the existing data with updated data directly for just one distinct record. This lecture is a little more computer science oriented and may be more advanced than some introductory courses would require, but this is good information to know and is part of the File I/O objects in Java, so I felt it was important to cover Random Access Files and how to work with them.

Working with Random Access files

In this lecture we take a short detour from working with files to see how we can work with Strings to pull the data from a formatted string, either with a pipe (|) or comma (,) delimiter. We take a look at two methods that can be used by the programmer to do this. The first method is to use the .split() function of a String object. This object automatically creates a String[] with each token from the split String in a separate index in the array. The other note about this option is that the .split function requires the use of a regular expression in Java. Regular Expressions are beyond the scope of our course, but I encourage you to read about them to find out what they are and how they work.

The second method for parsing out data from a formatted String is to use the StringTokenizer object. Unlike Split, we don't get direct access to each token at index, however we get an object that can easily be iterated and used to pull each token in order for use in our code.

During our lecture we also make note of the usefulness of these methods, the differences between the two, and how using one of them should easily allow us to bulk load some data in our systems, such as the autolot program.

String parsing using Split and String Tokenizer

Our "Putting It All Together" lecture this week shows how to use the information we've learned so far with files and serialization. The main changes to our program allow us to easily save and restore the state of our AutoLot system. This makes it possible to provide a way for the dealer to be able to store their work and not have to enter vehicles every time they want to work with the system. Additionally, we provide a new "bulkload" function, which reads a pipe-delimited file containing data about some vehicles. By adding in this functionality, a dealer could now easily load a new set of vehicles without having to create each vehicle individually. In the end, our program becomes much more user-friendly and powerful with these simple additions.

PIAT: Autolot with Files and Serialization

Our final lecture for section ten involves using the tools we've learned to save and restore the state of a game in progress. Now that we can serialize objects and store them in a file, we can easily make the grid and all of it's items serializable. When the user enters SAVE we can then save the current state of the grid to the default backup file. Typing RESTORE allows the user to easily start from where they last saved a grid in progress.

Sudoku Part 10: Save and restore a game in progress
Sample Code for Section 10
  • Willingness to learn
  • A few hours a week to review videos and a few more hours to work with the code individually.
  • The course is oriented towards those using Windows, however any computer that runs java can be used.

This course provides instruction through video lectures and materials which will teach (you) the student how to program in Java from the very basic level to an intermediate level of programming. The intent is to aid anyone who is struggling in learning how to program and would like to see practical examples and demonstrations. This course is not affiliated with any university and will not provide answers to any homework assignments for any reason. Topics covered will include but not be limited to:

  1. Syntax and commands
  2. Creating variables
  3. Creating methods
  4. Working with files
  5. Exception handling
  6. Creating Classes
  7. Object-Oriented programming basics
  8. Basic Unit Testing
  9. Graphics and GUI programming

In the end, this course is a stand-alone course, however it would be a huge aid to the online student who is taking a self-directed course, an individual who is trying to learn how to program, or even a high school student looking to get a head start on computer science material they might encounter in college. The material is organized in a start-to-finish fashion, building on knowledge with each section, so it is best to proceed through each section in order. Each section should amount to about a week worth of learning, lining up with most popular online course formats. Additionally, the course works hard to build practical knowledge that will help a student excel in their coursework, and also builds a strong foundation for a start to a career in programming for anyone looking to learn!

As an added bonus, several useful programs are built throughout this course, and the end result of the course includes full source code for a working Sudoku game, amongst other programs, such as card game score calculators and basics physics formula calculation programs.

Who this course is for:
  • Beginning programmers
  • Programmers making a switch to Java from another language
  • Online Programming students in Java courses
  • Advanced High School Students who want to get a jump on university level programming courses in computer science/management information systems.