Java for Beginners
4.3 (26 ratings)
Instead of using a simple lifetime average, Udemy calculates a course's star rating by considering a number of different factors such as the number of ratings, the age of ratings, and the likelihood of fraudulent ratings.
1,360 students enrolled
Wishlisted Wishlist

Please confirm that you want to add Java for Beginners to your Wishlist.

Add to Wishlist

Java for Beginners

Master java basics
4.3 (26 ratings)
Instead of using a simple lifetime average, Udemy calculates a course's star rating by considering a number of different factors such as the number of ratings, the age of ratings, and the likelihood of fraudulent ratings.
1,360 students enrolled
Created by Marius Claassen
Last updated 9/2017
English
Current price: $12 Original price: $20 Discount: 40% off
3 days left at this price!
30-Day Money-Back Guarantee
Includes:
  • 5 hours on-demand video
  • 54 Supplemental Resources
  • 25 Coding exercises
  • Full lifetime access
  • Access on mobile and TV
  • Certificate of Completion

Training 5 or more people?

Get your team access to Udemy's top 2,000 courses anytime, anywhere.

Try Udemy for Business
What Will I Learn?
  • At the end of this course, you will be able to: read Java code, develop basic Java applications and devise Java solutions when you are given a problem statement
View Curriculum
Requirements
  • Basic knowledge of computers
  • Able to download and install software
Description

Java for Beginners was published on 5th May 2017.  There are now already 1,350 students enrolled.  

In this course you will learn programming, the easy way, by using the world’s most widely-used language to:

* discover that anyone can code in Java
* write your own programs
* be in demand world-wide
* do Android coding (You must know Java to do Android programming)

There are 54 lectures that are on average 5 minutes long.  Every lecture includes a:

* video 
* PDF 
* lesson transcript
You can download these resources to do your personal study and review.  

Also, this course has a total of 25 coding exercises in order to practice what you have learnt.

Lectures start with a brief explanation of the lesson topic.  This includes animations, diagrams and images.  It is followed by working through a problem statement with expected output and suggested solution.  I then do some live coding to implement the solution and produce the expected output.  The lecture ends with a coding exercise for you to complete.  In the next lecture I go on to explain the solution

The 6 main topics you will study in this course, are: 

* Introduction
* Java basics
* Arrays
* Exceptions
* Java classes
* Conclusion

The sooner you enroll in this course the sooner you will gain mastery of programming basics.

Please note that you have an unconditional 30-day money back guarantee.  If you are not happy with this course you will get a full refund after 30 days.


Who is the target audience?
  • Complete beginner programmers
Compare to Other Java Courses
Curriculum For This Course
54 Lectures
04:46:20
+
Introduction
3 Lectures 16:14

Java 8 for Complete Beginners

Lecture 1: Course overview

Java 8 for Complete Beginners will help you to master the basics of programming.

In this course you will learn programming the easy way, by using the world's most popular language to:

* discover that anyone can code in java
* write your own programs
* be in demand world-wide

Hi there, my name is Marius from AlefTav Coding and in this talk I will provide an overview of my course, Java 8 for Complete Beginners.
A little bit about myself.  I am a java developer and teacher.  In fact, I taught myself to program, using java.  I was a teacher for many years, but now I'm working full-time as a software instructor, making video tutorials.  

At the end of this course you will be able to:

* read java code
* develop basic Java applications
* devise solutions when given a problem statement

There are 6 main topics you will learn.  They are:  An introduction, followed by the basics of Java.  Then, brief discussions of the three concepts: Arrays, Exceptions and Classes.  I conclude with some final remarks.
This course has 54 lectures that are, on average, 5 minutes long.  Each lecture includes a video, a PDF and a lecture transcript for your review and personal study.  Coding exercises are provided to re-inforce what has been learnt.

Lectures start with a brief explanation of the lesson topic.  This includes animations, diagrams and images.  It is followed by working through a problem statement with expected output and suggested solution.  I then do some live coding to implement the solution and produce the expected output.  The lecture ends with a coding exercise for you to complete, and which is solved in the next lecture.
 
I designed this course with the complete beginner in mind.  That is,  a person who wants to learn programming by watching how someone else does live coding.  The student then practices by doing a coding exercise on the course site.  Immediate feedback is given on the student's answer.  In the following video I explain the solution to the coding exercise. 

The sooner you enrol in this course the sooner you will gain mastery of programming basics.
Please note that you have an unconditional 30-day money back guarantee.  If you are not happy with the course you will get a full refund after 30 days.

My name is Marius from AlefTav Coding.  Thank you for listening and see you in the next video.


Preview 03:53

Lecture 2: Java Overview

Hi there, My name is Marius from AlefTav Coding, and in this lecture I will provide a brief overview of Java, the language.

Question: What is Java?  
Answer: Java is a general-purpose computer programming language.  In fact, it is the most widely-used programming language id the world.  Created by the Canadian, James Gosling, Java's first public release was in 1995.  Today, Java is used to write programs for every industry, whether it be business enterprise software, Android mobile phone apps, games or the internet of things.

Conclusion: If you have Java skills not only will you be in great demand, but you will also earn an above-average salary anywhere in the world, whatever the industry you choose to specialise in.
I am Marius from AlefTav Coding.  See you in the next video, where you will learn about the tools to create Java programs.



Preview 06:08

Lecture 3: Development tools

Hi there again, My name is Marius from AlefTav Coding, and this is the third lecture of my course, Java 8 for complete beginners. 

In this lecture you will learn how to download and install the tools needed for writing Java programs.

Now, in order to write a Java program, you need two things: number 1 - the Java Development Kit (JDK) and number 2 - a source code editor in which you type your java programs.  The term used for the code editor is, 'integrated development environment' or in short, 'IDE'.
 
The JDK is needed to compile and run Java programs.  While the IDE allows you to write the programs.  In this course, I will use the current latest Java development kit, (JDK 8).   The IDE I use is IntelliJ IDEA.  One of the reasons is that many of the world's best java developers use IntelliJ as their preferred IDE.  The two other major Java IDE's are Eclipse and Netbeans.

In addition to the JDK and IDE, you need an internet connection with a browser to download these two tools.  I am using Google Chrome.

To download the JDK, go to Google, then type 'JDK 8 download', and select 'Java SE development kit 8 downloads'.  You will be directed to the Oracle downloads page.  Accept the licence agreement for the latest development kit, and download the JDK for your particular machine.  Mine is a windows x64 machine.  So I selected the JDK8 for windows x64 option.  This download process takes a few minutes to complete.

If you don't know which Java version to download, then if you have Windows 10 installed, click on 'start', then in the 'search window' type  the words, 'This PC' and click on the 'This PC' option.  Right click on 'This PC' and select 'Properties'.  The 'System type' will show your processor type.

Next, to download IntelliJ, go back to Google and type in the search bar, 'download IntelliJ IDEA' and press enter for this download page.  I chose 'Windows' and the 'Community' edition.  Community is the free version of IntelliJ.  This download process also takes a while to complete.

On Windows the JDK and IntelliJ will be downloaded to the default 'downloads' folder. Next click on the JDK file to install the jdk on your computer.  Follow the directions by clicking 'next'.  

Afterwards click on the IntelliJ file to install it on your computer.  Again, follow the directions by clicking 'next'.  I want a desktop shortcut so I select the 64-bit launcher checkbox option, and for 'create associations' I select the '.java' checkbox.  All java files will automatically by opened in IntelliJ.  Click 'install'.  Install will also take a while to complete, but when it is finished, select the checkbox, 'Run IntelliJ IDEA' and click 'finish'.

IntelliJ will now start up.  The first time you run IntelliJ you will need to customise the IDE.  For our purposes, click 'skip all and set defaults'.  And you will shortly see the 'Welcome to IntelliJ' menu.  
 
In this lecture you learned how to download and install the development tools in order to write your first Java program in the next lecture.
 
I am giving this course away for free for a limited period.  For details on how to enrol, please email me at mariusclaassen@gmail.com

This is Marius from AlefTav Coding.  See you in the next video.

Preview 06:13
+
Java Basics
24 Lectures 02:06:39

// Lecture 4: Hello, world

// EXAMPLE PROBLEM STATEMENT: Print 'hello world'
// EXAMPLE SOLUTION: System.out.print("hello world");
// hello world

Hi there, My name is Marius from AlefTav Coding.  In this lecture you will learn how to print out on screen the 2 words, 'hello world'.  Now, 'Hello, world' is the first complete program you write when learning a programming language.  

A java program contains what are called 'classes'.  Here I have created one class, with the name 'Lecture4'.  When giving your Java classes a name the first letter of every word in the name of the class should be uppercase as the letter 'L' here.  And if the name of the class is made of more than one word, there are no spaces between the words that make up the class name, here the letter 'e' and the '4'.  This class is 'public', which means it can be accessed from anywhere.  And the code of this class must appear between these two curly braces.  

For a Java 'class' to be useful, you must have at least one 'method'.  A 'method' is java code which indicates an action to be performed.  The method created here is a 'main' method, which is where a Java program starts.  In this heading the word, 'public', again, means accessible from anywhere, 'static', is a word I will explain in a future lecture.  'void' means this method does not produce a value that can be passed to another method.  'main' is the name of this method.  These 4 words start with a lowercase letter, but this word 'String' starts with an uppercase letter.  And it is followed by 2 square brackets and the word 'args', short for 'arguments'. 
The code for my 'main' method must appear between these 2 curly braces.
To print something in Java you need to type this statement, 'System.out.print'.  'System' uppercase 'S', but 'out' and 'print' lower case starting letters.  'print' is a method that needs to be followed by 2 round braces.  In these braces are the words, 'hello world' which in turn must appear in quotation marks.  To complete a Java statement you add a semi-colon.  Finally, when you run this program, the 2 words, 'hello world' are printed on your screen. 

In IntelliJ, I have the lecture number 4, lecture topic 'Hello, world', the example problem statement, example solution, and the printout I want to see displayed by my program.

Next, I have a class 'Hello world' with a method 'main'.  Let me type in this statement as per my example solution, 'System.out.print("hello world");'

The green tick mark here is an IntelliJ feature which indicates everything is in order.  I can now run my program by selecting 'run', then 'run Lecture4'.  Here I can see a striped line for compiling this .java file into a .class file.  And the solid line for translation into machine-readable code.  I want to see these 2 words displayed here in the IntelliJ output window.  And, as expected the words, 'hello world' displayed here in the output window.
  
Success, the words expected have been displayed by my program.

In this lecture you've learned to print the 'hello, world' greeting.  Next, try the First coding exercise.

// FIRST CODING EXERCISE:
// Replace the comment with a statement to print the name, 'Adam'

In the coding exercise go to this line with the comment, delete it, and then type your answer there.  Let me put the line back.

My name is Marius from AlefTav Coding.  Till next time, KEEP CODING.

Preview 08:13

Lecture 5
1 question

// Lecture 5: First Coding Exercise Solution

// FIRST CODING EXERCISE: 
// TODO: Replace the comment with a statement to print the name, 'Adam'

// FIRST CODING SOLUTION: 
// System.out.print("Adam");

// Adam

Hi there again, this is Marius from AlefTav Coding with lecture 5 of my course, Java 8 for complete beginners.  In this lecture I will show you the solution of the first coding exercise.

I have here one-line comments.  Two forward slashes like this indicate a one-line comment.  Anything typed after them in a line is ignored by Java.  

In the last lecture, we looked at how to print the 2 words, 'hello world'.  And your homework was this coding excercise, TODO: Replace the comment with a statement to print the name, 'Adam'.

I have set up here a class, 'Lecture5' and a method, 'printAdam'.

The first requirement is to do a 'print'.  In Java the statement to print is, 'System.out.print'.  Next, this word, 'print' in Java is a 'method'.  Being a method it must be followed by 2 round braces.  Then, the final requirement here is to print the word, 'Adam'.  In Java to print text you must put that text between quotation marks, like this, "Adam"
Lastly, to end a java statement you must add a semi-colon.

  
In this lecture we looked at how to solve a coding exercise.  The format of the excercises that follow will be similar to this one.

My name is Marius from AlefTav Coding.  Till next time, KEEP CODING.

Preview 04:19

// Lecture 6: Primitive Data Types: Declaration Examples

// EXAMPLE PROBLEM STATEMENT: 
// Declare Java's 8 primitive data types 

// EXAMPLE SOLUTION: 
// byte byteValue, short shortValue, int, long, float, double, boolean, char

Hi there, I am Marius from AlefTav Coding.  In this lecture you will learn to declare java's 8 primitive data types. 

In a Java program there are many storage locations where different pieces of data are stored.   Each one of these storage locations must first be 'declared' before your java program can use it.  The declaration pattern in Java is: dataType storageName.  You first identify the type of data that can be stored at a location, and then you give that storage location a name.  So that you can refer to that storage area whenever you want to work with that data.  
This is called a declaration.

Java has two main ways of storing information.  These 2 ways are 'reference' types, which you will learn later on in this course, and 'primitive' types.  

Now, 'Primitive' data types are storage locations where the name of the location and the value being stored are the same.  For example, here we have a storage area where a discrete, whole number can be stored, dataType 'int', storageName 'intValue' .  And here is another area which can store a fractional number, indicated by the period in the number, dataType 'double' storageName 'doubleValue'.  And here is a 3rd location where a character can be stored, indicated by the 2 single quotation marks, dataType 'char' storageName 'charValue' .  And, finally, we have a location which can store only a 'true' value or a 'false' value, dataType 'boolean' storageName 'booleanValue'.

Here in IntelliJ I have created a class, 'Lecture6' with a 'main' method.

My problem statement requires me to declare Java's 8 primitive data types.  These types are: byte, short, int, long, float, double, boolean and char.

I will use the declaration pattern in Java as follows: dataType storageName

For working with whole numbers, positive and negative, java provides the following 4 from the smallest size to the largest size:
byte byteValue;
short shortValue;
int intValue;
long longValue;

Then, for working with fractional numbers, again positive or negative, java provides the following 2:
float floatValue;
long longValue;

For working with values that can either be 'true' or 'false', Java defines:
boolean booleanValue;

Finally, for defining a single character, Java provides: 
char charValue;

In this lecture you've learned how to declare Java's 8 primitive types.

Now, do this coding exercise. 

// PRIMITIVES DECLARATION CODING EXERCISE:
// Declare a 'char' data type, named ‘letterY’
 
My name is Marius from AlefTav Coding.  Till next time, KEEP CODING.

Preview 06:20

Lecture 7
1 question

// Lecture 7: Primitive types: Declaration Solution

// PRIMITIVES DECLARATION CODING EXERCISE:
// Declare a 'char' data type, named ‘letterY’.

// PRIMITIVES DECLARATION SOLUTION:
// char letterY 

Hi there, my name is Marius from AlefTav Coding.  In this lecture I will provide the solution to the declaration coding exercise. 

The problem statement is to declare a 'char' data type, named ‘letterY’.  

In Java the declaration pattern is dataType.  In this our type must be 'char'.  And the next part of the declaration pattern is storageName.  Here we are asked to give the name of the storage area, 'letterY'.  And to complete my java statement I add a semi-colon.

IntelliJ's green tick mark here is an indicator to me that my code is correct.  Now let me run my program to make absolutely sure this code is working ok.  So, I click 'run', then again 'run', then Lecture 7.  And I am waiting for the compiling and machine code translation.  There will not be any printout in the output area, because I did not do a 'System.out.print' statement.

In the next lecture you will learn to initialize a primitive data type.

I am giving this course away for free for a limited period.  For details on how to enrol, please email me at mariusclaassen@gmail.com
 
This is Marius from AlefTav Coding.  Till next time, KEEP CODING.

Preview 02:26

// Lecture 8: Primitive types - Initialization Example

// EXAMPLE PROBLEM STATEMENT: Initialize an integer number 900
// EXAMPLE SOLUTION: ***

Hi there, this is Marius from AlefTav Coding.  In this lecture you will learn to initialize a value. 

In the last lecture we looked at declarations in Java using the pattern 'dataType storageName'.  Now, after you've told Java the type of data to store at a particular location, you can put an actual value at that location.  For this step, Java uses another pattern, 'storageName = value'.  We say, we 'assign' some 'value' to the location named 'storageName'.  The equals symbol means assignment.  The technical term for this process is 'initializaion'. 

Let's say I have 'declcared' that at this location only whole numbers can be stored.  Then I can place here a whole number such as 900, because it is a whole number.  And, let's say I have 'declared' that at this location only single characters can be stored.  Then I can decide to sotre here a character such as 'a', because 'a' is a single character.  I have 'initialised' a whole number, in java an 'int' type for integer, and a single character, in java a 'char' type.

Now, let me solve this problem here, where I am asked to 'initialize' an integer value, 900.  

Let me implement this initialization in Java code:

In the last lecture I did an int declaration like so, int intValue;
Now, I will initialise my storageName, 'intValue' with the whole number 900, 'intValue = 900;  
I am telling Java to place the number, '900' at the location named 'intValue'.  And as always, I must add a semi-colon to complete my statement.  

I can combine the 2 steps, declaration and initalization, into one step like this:  int intValue = 900;
These 2 lines of code is exactly the same as this one line of code.

And this green tick mark indiccates that my code is working correctly.  And to make sure I will click 'run' and again 'run', then 'Lecture8'.  After the compliling and execution I will see in the output window no result appears.  Because I did not do the print statement 'System.out.print'.  But since this output area does not show any error messages the program is correct.

Here are a few more combined declarations and initalizations:
byte byteValue = 14;
int intValue = 71
short shortValue = 3_200;  I am using the underscore after the 3rd digit for increased readability of this number.
long longValue = 456_700;  

float floatValue = 1_500.2f;  The 'f' indicates this is a 'float' type, other Java will assume this as a 'double' data type.
double doubleValue = 293_680.7; 

boolean booleanValue = true; 

char charValue = 'a';

In this lecture you've learned to initialise primitive data types.

Now, to practice what you've just learned, do this coding exercise below. 

// PRIMITIVES INITIALIZATION CODING EXERCISE:
// Initialize the char data type ‘letterY’ with the value ‘Y’

My name is Marius from AlefTav Coding.  Till next time, KEEP CODING.

Primitive Data Types: Initialization Example
05:24

Lecture 9
1 question

// Lecture 9: Primitive Types: Initialization Solution

// PRIMITIVES INITIALIZATION CODING EXERCISE:
// Initialize a char data type named ‘letterY’ with the value ‘Y’

// PRIMITIVES INITIALIZATION SOLUTION:
// char letterY = 'Y';

Hallo again, I am Marius from AlefTav Coding.  In this lecture you will learn the the solution to the initializaion coding exercise. 

The coding exercise required you to 'initialize a 'char' data type named 'letterY' with the value 'Y', uppercase letter 'Y'.   Looking at our expected solution, you use the Java pattern, 'dataType storageName = value'.  The problem statement says the dataType must be a 'char'.  And there is the char.  Then, it also says the storageName must be 'letterY', and there it is.  And, finally, the value you needed to store is 'Y', here.  In single quotes, because that is how y Java recognized that a value is of dataType char. 

Now, lets type this solution code in our program.  We have a class, 'Lecture9' with one method, 'setLetterY'.  I remove this 'todo' comment and then type the solution dataType 'char' storageName 'letterY' initialized as uppercase letter 'Y' in single quotes and a semi-colon.
 
In this lecture you learned the solution to the initializaion coding exercise.  

Next time we will look at operators in Java.
 
This is Marius from AlefTav Coding.  Till next time, KEEP CODING.

Primitive Data Types: Initialization Solution
03:10

// Lecture 10: Java Operators Examples (*,  /,  %,  +,  -,  <,  >=,  !=,  =)

// EXAMPLE PROBLEM STATEMENT: 
// Assign '11 * 18' to a 'short' data type named 'answer1'

// EXAMPLE SOLUTION: 
// short answer1 = 11 * 18; 

Hi there, this is Marius from AlefTav Coding.  In this lecture you will learn to use operators in Java. 

Operators are special symbols used in order to calculate a result.  Some of these operators are, here, *,  /,  %,  +,  -,  <,  >=,  !=,  =  

The example problem for this lecture states that you must 'assign 11 * 18 to a short dataType named answer1'.  In other words you have to store the result of the multiplication, '*' expression '11 * 18' at a storage location, named 'answer1'.  

In our expected solution, again, we use the Java pattern 'dataType storageName = value'.  The requirement says the dataType must be 'short', there it is.  Then, the storageName must be 'answer1', here.  Finally, the initialization or assignment must be '11 * 18'.  There it is.

Now we can look at our program.  Our class is 'Lecture10' with a method, 'main'. And the code is 'short answer1 = 11 * 18;' 

In this lecture you learned to use operators in Java.

To re-inforce what you've just learned, do this coding exercise. 

// JAVA OPERATORS CODING EXERCISE:
// Assign '40 - 13' to a 'byte' data type named 'answer5'

My name is Marius from AlefTav Coding.  Until next time, KEEP CODING.

Java Operators Example
04:29

Lecture 11
1 question

// Lecture 11: Java Operators Solution

// JAVA OPERATORS CODING EXERCISE:
// Assign '40 - 13' to a 'byte' data type named 'answer5'

// JAVA OPERATORS SOLUTION:
// byte answer5 = 40 - 13;

Hi there, again, My name is Marius from AlefTav Coding.  In this lecture you will learn the solution to the operator coding exercise. 

This exercise asks you to 'assign '40 - 13' to a 'byte' data type named 'answer5'.   In the expected solution, again, you use the Java pattern, 'dataType storageName = value'.  The problem statement says the dataType must be a 'byte'.  And there is the byte.  Next, it says the storageName must be 'answer5', there it is.  And, finally, the value you needed to store is '40 - 13', here.  Java will calculate the answer of this expression and put at the storage location named 'answer5'.

Before typing this solution code in our program, you see here a class, 'Lecture11' with one method, 'setAnswer5'.  Let me remove this 'todo' comment and type the solution dataType 'byte' storageName 'answer5' initialized as 40 - 13' and a semi-colon.
 
In this lecture you learned the solution to the operator coding exercise.  

So far you have learned how to use Java's primitive data types.  In the next lecture we will look at Java's reference data types.
 
I am Marius from AlefTav Coding, and, as always, my signing off is to KEEP CODING.

Java Operators Solution
03:32

// Lecture 12: Reference Types Example

// EXAMPLE PROBLEM STATEMENT: 
// Declare a String named 'mySignOff' initialized as 'Keep coding'

// EXAMPLE SOLUTION: 
// String mySignOff = "Keep coding";

Hi there, this is Marius from AlefTav Coding.  In this lesson you will learn to declare and initialize a reference type.

A 'reference' holds the value of a storage location SOMEWHERE ELSE.  This is the key with a reference, the location where the value is stored, is entirely different from the storageName location.

Let's briefly revise primitives from the last few lectures, where the storageName and the value it holds are the SAME location.  When you type the declaration, 'int myNumber', Java sets aside a location of a certain size where only whole numbers can be stored.  It will remember this location by the name, 'myNumber'.  Then, when you assign the value 700 to 'myNumber', Java will store the 700 at this location.   

A 'reference' is completely different.  Let me use the reference data type called 'String'.  When you type the declaration, 'String mySignOff', Java sets aside a location which holds the value of an area SOMEWHERE ELSE.  And Java will remember the name, 'mySignOff', holds the value of this other location.   
Then, when you assign 'mySignOff' to the words, 'Keep coding', Java will store the words, 'Keep coding' at this other location.  We say that 'mySignOff' is a 'reference' to the location where 'Keep coding' is stored.

The example problem for this lecture states that you must 'declare a String named mySignOff initialized as 'Keep coding'.  

In our expected solution, again, you use the Java pattern 'dataType storageName = value'.  The requirement says the dataType must be 'String', uppercase first letter 'S'. Here it is.  Then, the storageName must be 'mySignOff'.  We have it here.  Finally, the initialization or assignment must be the text, 'Keep coding'.  There it is, in quotation marks, because this is how Java knows these are words of text.

Now we can look at our complete program.  It has a class 'Lecture12' with a method, 'main'.  I will type this solution code to end this lecture, by removing this 'todo' comment.  'String mySignOff = "Keep coding";  

  
In this lecture you learned about the tricky concept of a Java 'reference' type.

Now, you can practice what you've just learned by doing this coding exercise. 

// REFERENCES CODING EXERCISE:
// Declare a String named ‘words’ initialized as ‘In the beginning’

My name is Marius from AlefTav Coding.  Till next time, KEEP CODING.

Reference Data Types Example
06:00

Lecture 13
1 question

// Lecture 13: Reference Types Solution

// JAVA REFERENCES CODING EXERCISE:
// Declare a String named ‘words’ initialized as ‘In the beginning’

// JAVA REFERENCES SOLUTION:
// String words = "In the beginning";

Hi there, This is Marius from AlefTav Coding.  In this lecture you will learn the solution to the reference data type coding exercise. 

You were required to declare a String named ‘words’ initialized as ‘In the beginning’.   In the expected solution, you see the Java pattern, 'declaration initialization'.  The problem statement says the dataType must be a 'String'.  Here we have 'String'.  Next, it says the storageName must be 'words', and here you are.  Finally, the value you needed to store is this here, 'In the beginning'.  There in quotation marks since it is text with a semi-colon.

We can now complete our program.  This program has a class, 'Lecture13' with one method, 'setWords'.  Let me remove this 'todo' comment and type the expected solution, the dataType is 'String', storageName 'words' initialized as "In the beginning" in quotation marks and a semi-colon.

 
And that is it for this lecture where you learned the solution to the java reference coding exercise.  

Next time, we will look at the situation where your java program asks you for information.
 
I am Marius from AlefTav Coding.  Till our next lesson, KEEP CODING.

References Solution
03:20

// Lecture 14: The Scanner Class Example

// EXAMPLE PROBLEM STATEMENT: 
// Write code to have Java ask for your name

// EXAMPLE SOLUTION: 
// System.out.print("What is your name? "); *** prints information
// marius ************************************* waits for user
// Scanner scanner1 = new Scanner(System.in); * reads user information
// String name = scanner1.next(); ************* stores user information
// System.out.print("Your name is " + name);*** prints user information
 
// What is your name? 
// Your name is 

Hello, I am Marius from AlefTav Coding.  In this lecture you will learn how to use the 'Scanner' class. 

'Scanner' allows java to ask you for information.  After you've typed that information, Java will 'scan' it in.

This example problem states 'write code to have Java ask for your name'   

In our expected solution here are 5 steps.  Firstly, Java prints text on your screen.  To print something in Java you use the 'print' statement. Notice this word 'out' for 'output'.  Here Java is asking a question, my name.  
Secondly, Java waits for the user to provide the information.  Here I answer the question by typing in my name.  
Thirdly, Java reads the user information with this statement.  Notice this word 'in' for 'input'.   Let's take a closer look at the reading in of the information.  This is a declaration of dataType 'Scanner'.  For this dataType Java requires extra information provided by this 'import' statement befor the start of the program.  Then the initialization is this code.  For the moment just note that this is initializing information read in by Java.
The fourth step is for Java to store the information typed by the user.  The 'name' that the user provides is text so, Java stores it as a String dataType.
Lastly, Java prints the information provided by the user.  This is to confirm that Java correctly read in the information.  This text is printed by Java and then I tell to add the value stored in the 'name' storageName.

Now let's look at our complete program.  Here a class 'Lecture14' with a method, 'main'.  I have already here this line of code where Java asks for my name.  I will now type these 3 lines of the solution code.  

Finally, we run our code to test that it works correctly and that these expected lines are actually printed.  I select 'run' then 'run 'Lecture14', and we wait for the compiling into intermediate '.class' files and translating into machine code.  

Java is asking my name, which I now provides.  And Java repeats my name, as expected.
  
  
In this lecture you've learned to use Java's Scanner class.

Now, for a practice session of what's been learned, here is the coding exercise for this lecture. 

// SCANNER CLASS CODING EXERCISE:
// Declare and initialize a String named 'language' as 'scanner1.next()'

My name is Marius from AlefTav Coding.  Till next time, KEEP CODING.

Scanner Class Example
06:15

Lecture 15
1 question

// Lecture 15: The Scanner Class Solution

// SCANNER CLASS CODING EXERCISE:
// Declare and initialize a String named 'language' as 'scanner1.next()'

// SCANNER CLASS SOLUTION:
// String language = scanner1.next();

Hi there, I am Marius from AlefTav Coding.  In this lecture we will review the solution to the scanner class coding exercise. 

You were required to 'declare and intialize a String named ‘language’ as ‘scanner1.next()'.   Here is our expected solution, where you see, by now the familiar  Java pattern, 'declaration and initialization'.  The problem statement says the dataType must be a 'String'.  Here we have 'String'.  Next, it says the storageName must be 'language', and here you are.  Finally, the value you store at the dataType 'language' is this code, 'scanner1.next()'.  And, as always, completing a Java statement text with a semi-colon.

Now to complete our program.  The class is, 'Lecture15' and there is one method, 'getLanguage'.  I will me remove this 'todo' comment and type this line of code, the dataType 'String', storageName 'language' initialized as 'scanner1.next()' and a semi-colon.

 
And this is what you had to type to solve this problem statement.

In this lecture we looked at the solution to the scanner class coding exercise. 
 
I am Marius from AlefTav Coding.  Till next time, KEEP CODING.

Scanner Class Solution
03:02

// Lecture 16: Conditional Operators Examples - && (AND), || (OR)

// EXAMPLE PROBLEM STATEMENT: 
// Implement the ‘&&’ operator where charJ = ‘J’ and charK  = ‘K’ 
// and print ‘charJ is J AND charK is K’.
 
// EXAMPLE SOLUTION: 
// if ((charJ=='J')&&(charK=='K')) 
// { System.out.print("charJ is J AND charK is K"); }

// charJ is J AND charK is K

Hi there, I am Marius from AlefTav Coding.  In this lecture you will learn how to use Java's conditional operators. 

Conditional operators are these special symbols that relate to true/false expressions.  This symbol means 'and' while this one means 'or'.  With '&&' ALL conditions must be true before Java will complete the code that follows.  But with the '||' operator only One of the conditions need to be true for Java to complete the code that follows.

In a previous lecture you learned that when you declare and initialize, lets say, char charJ = 'J', Java puts the uppercase letter 'J' at a storage location like this.  In the same way, when you type char charK = 'K', Java puts the uppercase letter 'K' at a storage location like this.

Going further, lets say, you want to find out if location 'charJ' has actually been initialized with the value 'J', what you do is to compare the location 'charJ' with uppercase 'J'.  Similarly, to check if location 'charK' has been initialized with value 'K', you compare the value at location 'charK' with uppercase 'K'. 
Java provides an 'if' statement for this purpose which you use like this 'if (charJ == 'J')'.  And 'if (charK == 'K')'.  You use 2 equals symbols together to compare primitives like a char dataType.

The first condition, 'charJ == J' and the second condition 'charK == K' must both be true when you use the conditional '&&' for this code to be executed.  If one condition is false Java will not complete this print statement. 

Turning to IntelliJ, this problem statement reads to 'Implement the ‘&&’ operator where charJ = ‘J’ and charK  = ‘K’ and print ‘charJ is J AND charK is K'.  The expected output is this statement because we use the '&&' operator and both conditions are true.  Then, our expected solution is an implementation of the '&&' operator as required here.  

My program has a class, 'Lecture16' with a main' method.  I have already declared and initialized 'charJ' and 'charK'.  Now, to implement the '&&' operator with the 'if' statement I will type this expected solution.  Now, let me run my program to test my code.  I want to see this output displayed here.

Please note that Java will execute this print statement because this '&&' operator requires that both this condition and this condition be true. 
And here is our printout, success.

Conditionals &&, || Example
07:53

Lecture 17
1 question

// Lecture 17: Conditional Operator Solution

// CONDITIONAL OPERATOR CODING EXERCISE:
// Implement the ‘||’ operator with evenNumber as 8 or oddNumber as 12 

// CONDITIONAL OPERATOR SOLUTION:
// if( (evenNumber == 8) || (oddNumber == 12) )

// evenNumber is 8 OR oddNumber is 12

Hi there, I am Marius from AlefTav Coding.  In this lecture I will review the solution to the conditional operator coding exercise. 

You were required to 'Implement the ‘||’ operator with evenNumber as 8 or oddNumber as 12'.  Here is our expected solution, the implementation of an '||' operator, as per this requirement.  You use an 'if' statement with 2 conditions.  In this first condition 'evenNumber' equals equals 8, the requirement here.  In the second condition 'oddNumber' equals equals 12, which is this requirement here.  You use the 'equals equals' symbols because you are comparing primitive dataTypes, 'int'.

Now in the actual program, here is a class, 'Lecture17' with a method, 'printConditionalOr'.  Then we have declared and initialized 'evenNumber' as 8 and 'oddNumber' as 9.  In this code block is a print statement 'evenNumber is 8 or oddNumber is 12'.  This first condition is true, because here we have 'evenNumber' initialized as 8.  But this second condition is false, because 'oddNumber' is initialized as 9 here and not 12.

With one condition true this print statement will be executed when you use the '||' operator.  Let me type this example solution here, 'if ( (evenNumber == 8) || (oddNumber == 12) ).

Let me test this program by selecting run. But first let me comment this line with the method, 'printConditionalOr' and uncomment the main method.  And here is our output.  I will reverse the comment and uncomment.

In this lecture we looked at the solution to the conditional operator coding exercise. 
 
 
This is Marius from AlefTav Coding.  Till the next lecture, KEEP CODING.

Conditionals Solution
07:10

// Lecture 18: If-Then and If-Then-Else Examples

// EXAMPLE PROBLEM STATEMENT: 
// Implement 'if-then-else' where int num1 = 56 and int num2 = 65,
// and print whether they are equal or not

// EXAMPLE SOLUTION: 
// if (num1 == num2) {System.out.print("56 is equal to 65");}
// else {System.out.print("56 is not equal to 65"); }

// 56 is not equal to 65

Hi there, I am Marius from AlefTav Coding.  In this lecture you will learn how to use the 'if-then' and the 'if-then-else' expressions in Java. 

'If-then' is a control flow statement where Java executes code only if a condition is true.  Here, these 2 numbers 21, are stored at different locations.  Java looks at the locations where these 2 numbers are stored, compares the numbers and prints the statement that they are 'equal'.  IF the first location, 'num6' is equal to the second location, 'num7' THEN print that they are equal.

With 'if-then-else', Java executes another piece of code if the first condition is false.  Here are another 2 numbers, 56 and 65, and again, they are stored at different locations.  Java looks again at the 2 locations and compares the numbers stored there.  It then prints the statement that they are 'not equal', and simply ignores the code that reads, 'equal'.  IF the first location, 'num1' is equal to the second location, 'num2' THEN print they are equal, ELSE print that they are not equal. 

Let's look at our problem statement.  'Implement if-then-else where int num1 is assigned to the value 56, and int num2 is assigned to the value 65 and print whether they are equal or not.  Looking at what I expect to see printed, it should be that they are not equal, here, because 56 and 65 are different integer values.  My example solution is, IF num1 equals equals num2 THEN print 'equal', ELSE print 'not equal'. 
The next part of the requirement is to do a printout and say if they are equal.  These 2 values are not equal so my printout should read, as here in the expected solution, that 56 is not equal to 65.
 

Now, to complete my program, I have a class, 'Lecture18' with a 'main' method.  Then, here are declared and initialized 'num1' and 'num2'.  And the 2 control flows, the first is to print 'equal' and the second control flow is to print 'not equal'.   All that is left is to print the 'if' statement with the one condition, in round brackets num1 equals equals num2.  And the reason I am using the equals equals symbols is that I am comparing 2 primitive dataTypes, int.  Everything is in order.  Now, let me run my program to test my code.  I want to see this output displayed here.  And there is the expected output.

In this lecture you've learned to use Java's if-then-else control statement.

Now, complete this coding exercise to practice what you've learned. 

// IF-THEN-ELSE CODING EXERCISE:
// Implement 'if-then-else' with testScore >= 60

My name is Marius from AlefTav Coding.  Till next time, KEEP CODING.

If-Then-Else Example
06:57

Lecture 19
1 question

// Lecture 19: If-Then-Else Solution

// IF-THEN-ELSE CODING EXERCISE:
// Implement 'if-then-else' with testScore >= 60

// IF-THEN-ELSE SOLUTION:
// if (testScore >= 60)

// pass

Hi there, I am Marius from AlefTav Coding with Lecture 19 of my course, 'Java 8 for Complete Beginners'.  In this lecture we will review the solution to the if-then else coding exercise. 

You were asked to 'Implement ‘if-then-else’ with testScore >= 60'.  Here is our expected solution.  You use an 'if' statement with only one condition, if the value of testScore is larger than or equal to 60.  

Now to complete your program, You have here a class, 'Lecture19' with one method, 'printIfThenElse'.  Then we have declared and initialized an int 'testScore' as 74 and a String 'result' as 'undefined'.  Looking further you see that your program has 2 control flows.  Firstly, assign the String 'result' to 'pass' if the value of testScore is greater or equal to 60.  The second control flow is to assign the String 'result' to 'fail' if the value of testScore is less than 60.  The value of testScore is initialized here to 74 which is greater than 60, therefore 'result' will be assigned to 'pass', and therefore we expect a printout of the String 'pass'.
I can now type the expected solution by deleting this 'todo' line, like this, if (testScore >= 60)

Let me test our program by commenting out the method 'printIfThenElse' and uncommenting the method 'main'.  Then run my program.   When you run your program, Java is looking for the method, 'main', the starting point of your program.  So, here to run my program I need to make sure Java can find 'main' to execute this code.  I should see the value 'pass' printed.  And, indeed, our program works as expected.  Let me comment and uncomment again.

In this lecture we looked at the solution to the if-then-else coding exercise. 
 
I am Marius from AlefTav Coding.  Till the next lecture, KEEP CODING.

If-Then-Else Solution
05:21

// Lecture 20: Switch Statement Example

// EXAMPLE PROBLEM STATEMENT: 
// Implement the 'switch' statement to print weekday 6 as 'Friday'

// EXAMPLE SOLUTION:
// switch(day)
// case "6": System.out.print("Friday"); break; 

// Friday
 
Hi there, I am Marius from AlefTav Coding.  In this lecture you will learn how to use the 'switch' statement. 

Java's 'switch' statement helps you to choose one option when there are many different available options.  It is more elegant to use than the 'if-then-else' statement that we studied in the previous 2 lectures.

Lets look at the 7 days of the week, day 1 is Sunday, day 2 is Monday, day 3 is Tuesday up to day 7 being Saturday.  From this list I want Java to choose day 6, and to print the word corresponding to 6 which is, 'Friday'.  We can do an animation like this, selecting day 6 to print, 'Friday',

Now for our problem statement, where we are asked to implement the 'switch' statement to print weekday number 6 as a String, 'Friday'.

In our expected output, this is the word that we expect to see printed out.

Before studying this solution to the problem statement, lets look at the structure of the 'switch' statement.
This is how a 'switch' statement looks.  As always, in Java we start with a declaration, and here also an initialization because we decided which day option we want, day 6.  Then, there is a list of available options from which we look for the chosen one.  I will come to this part later in this lecture.  Each option is named, 'case' with the initialized values following.  These are dataType 'String', a colon and a print statement that outputs the value to be printed.
Important, next is this keyword, 'break'.  When Java has found the option we want, it must be told to stop searching through the remaining options.  This is why we have to tell Java to 'break' out of this code block. 
Also, I need to ensure my program handles values that are outside of this normal range 1 to 7.  And Java is good enough to help me in this regard with a keyword, 'default', so that I can display an error message, let's say, 'Invalid weekday', 'break'. 

In the solution, Implementing the switich statement means to type the keyword, 'switch'.  And the storageName to be switched on is 'day'.  The option selected or 'case' is 6, in quotation marks, because I declared my dataType as a String.  This is followed by a colon symbol, my print statement and the keyword, 'break'.

Now to complete my program.  I have a class, 'Lecture20' with a main method.  Then a declaration and initialization.  Now I implement in this comment, 'switch (day)'  And then here, case "6": System.out.print("Friday"); break; 

With my code being given the all-clear from IntelliJ with this green mark here, I will run the program.  And I expect to see printed here the word, 'Friday' 
And there we are, right on time.

In this lecture you've learned to use Java's switch statement.

Now, after you have studied the information in this video here is this lecture's coding exercise. 

// SWITCH CODING EXERCISE:
// Implement the ‘switch’ statement to print calendar month 3 as ‘March’  

My name is Marius from AlefTav Coding.  Till next time, KEEP CODING.

Switch Example
05:52

Lecture 21
1 question

// Lecture 21: Switch Solution

// SWITCH CODING EXERCISE:
// Implement the ‘switch’ statement to print calendar month 3 as ‘March’ 

// SWITCH SOLUTION:
// switch(month)

// March

Hi there, This is Marius from AlefTav Coding.  In this lecture I will provide the solution to the switch statement coding exercise. 

The problem statement here is 'implement the 'switch' statement to print calendar month 3 as 'March' 

The expected output, here, is to see the month, 'March' displayed  In the expected solution, you type the keyword, 'switch', the requirement here.  Then we need to switch on the storageName, 'month', which is this requirement.  

Now to complete your program, You have here a class, 'Lecture21' with one method, 'printMonth3'.  We have declared and initialized a String 'month' as '3' and the available options or cases.  Each of the 12 cases represents a month of the year.  When a month is initialized here, that month is selected in this list and is then printed as a String.  Each option is followed by the keyword 'break'.  The last option is an 'invalid month', that is printed if you initialize a month that is outside this range of 1 to 12.  
I can now complete this program with the expected solution.  Deleting this 'todo' line and then typing, 'switch(month)'

To test our program I will comment out the method heading 'printMonth3' and uncomment the method header 'main'.  Then run the program.  I should see the value 'March' printed.  And, success, our program works correctly.  Let me comment and uncomment again.

In this lecture we solved the switch coding exercise. 
 
I am Marius from AlefTav Coding.  See you in the next video when we will start looking at Java features to help you dealing with very large amounts of data.
So till next time, KEEP CODING.

Switch Solution
04:24

// Lecture 22: For Loop Example

// EXAMPLE PROBLEM STATEMENT: 
// Implement a 'for' loop to print the five values 24 to 28

// EXAMPLE SOLUTION:
// for (int j=24; j<29; j++) { System.out.print(j+" "); } 

// 24 25 26 27 28
 
Hi there, This is Marius from AlefTav Coding.  In this lecture you will learn how to use Java's 'for' loop. 

In order to process large amounts of information, you need to do the same action again and again, repeatedly, until you reach a stop.  You must have a stop condition, because Java will happily carry on otherwise.  

For this type of situation Java provides 3 statements.  Firstly, a 'for' loop, which we will look at in this lecture, a 'while' loop which you will study in the next lecture, and thirdly, a 'do-while' loop, which is the topic of the lecture after that.

So, as I said, the 'for' loop provides a way to handle lots and lots of information.

Let's look at our problem statement.  'Implement a 'for' loop to print the 5 values 24 to 28'.
Our expected output are these values, here, 24 is value one, 25 is value two, 26 is three, 27 is four and 28 is five.

The structure of the 'for' loop is here in the example solution.  First the keyword, 'for', and being a Java keyword it starts with a lowercase letter.  This is followed by these 2 round braces.  And inside is our 'for' loop condition.  In this condition we must have 3 parts: The starting point here, the end-point here, and the calculation here to move from the start to the end.  So, we start at value 24, declaration and initialization, 'storageName j as 24'.  

The problem statement says the end value must be 28.  To get to 28, I am using here a 'less than' symbol to stop the repeated action when it is less than 29.   This is saying add one everytime to whatever the previous value was.  Next a print statement, displaying the values of storageName 'j', and add a space, before printing the next value.

So, starting at 24, then checking 'is 24 less 29?' yes, then add one to 24 to get 25.  Next round, check is 25 less than 29? yes, then add one to 25 to get 26.  Again, check is 26 less than 29?  yes, then add one to 26 to get 27.  And so on till 29, check, is 29 less than 29? no.  Then stop and 29 is not printed at all.

To complete my program.  I have a class, 'Lecture22' with a main method.  Now I remove the single line comment and type, 'for (int j = 24; j<29; j++)'.  
When I run my program I expect to see 24, ... 28.  And.. success.

In this lecture you've learned to use Java's for loop statement.

Now, to practice what you learned, do this coding exercise. 

// FOR LOOP CODING EXERCISE:
// Implement a ‘for' loop to print the three values 87 to 89

My name is Marius from AlefTav Coding.  Till next time, KEEP CODING.

For Loop Example
06:53

Lecture 23
1 question

// Lecture 23: For Loop Solution

// FOR LOOP CODING EXERCISE:
// Implement a ‘for' loop to print the three values 87 to 89
 
// FOR LOOP SOLUTION:
// for (int j=87; j<90; j++)

// 87 88 89

Hi there, I am Marius from AlefTav Coding.  In this lecture we will study the solution to the 'for' loop coding exercise. 

The problem statement says implement a 'for' loop to print the 3 values 87 to 89.

Our printed values should be as here, 87 88 and 89, starting at 87 and ending at 89.

In our solution we hava a 'for' loop.  Inside the following round brackets our condition is to start at 87 here and stopping before 90, here.  So, the first part is to have a dataType int, storageName 'j' initialised as 87 and semi-colon.
Then, our ending range value is less than 90 to get 89 as per the requirement here.  
Next we add one to each value as we increase in number at every iteration.  

I can now complete this program with the expected solution.  But before that I have a class 'Lecture23' with a method 'printForLoop'.  Then deleting this 'todo' line and then typing, 'for(int j=87; j<90; j++)'

Again, to test our program I will comment out the method heading 'printForLoop' and uncomment the method header 'main'.  Inside the curly braces code block I have my print statement with the values of 'j' with a space added after each value.

Then run the program.  I should see the values '87 space 88 space 89' printed.  And, success, our program works correctly.  Let me comment and uncomment again.

In this lecture we looked at the solution to the 'for' loop coding exercise. 
 
I am Marius from AlefTav Coding.  and until next time, KEEP CODING.

For Loop Solution
04:16

// Lecture 24: While Loop Example

// EXAMPLE PROBLEM STATEMENT:
// Implement a 'while' loop to print the four values,
// divisible by 5, from 40 to 55

// EXAMPLE SOLUTION:
// int j=40; while (j<=55) { System.out.print(j+" "); j=j+5;}

// 40 45 50 55 
 
Hi there, I am Marius from AlefTav Coding.  In this lecture you will learn how to use Java's 'while' statement. 

The 'while' loop is another way to handle large amounts of information in Java.  But, just as is the case with the 'for' loop, you have to place a condition in the while loop to stop its operation.

The problem statement for this lecture is 'Implement a 'while' loop to print 4 values, divisible by 5 from 40 to 55'.  

For the output the first value is 40.  Is 40 divisible by 5? yes, 40 divided by 5 is 8.  The next value after 40 divisible by 5 is 45, the second of the expected answers, then 50, the 3rd value and finally, 55, the 4th value as per the requirement.

Now to our example solution.  Just as the case with the 'for' loop we have 3 parts.  Firstly, the starting point, this time before the code block.  Then the end-point and finally the calculation inside the code block to move from starting point to end-point.  So, here we place the declaration and initialization before the start of the while code block.  The int 'j' assigned to the first value, 40.
Then, starting the 'while' statement with the test condition inside these round brackets.  I will say 'less than or equal to' 55 and use these 2 symbols for the condition to end this loop.
Inside the loop, I will have a statement to do the printing of each value, and adding a spacing after the value.  Then, I also need to tell Java that, when a value is printed, to add 5 to that value. 40 plus 5 is 45 plus 5 is 50, plus 5 is is 55.
 
Next to complete my program.  I have a class, 'Lecture24' with a main method.  Then a declaration and initialization.  Now I implement in this comment, 'while (j<=55)'  And inside the code block, System.out.print(j+" "); j=j+5; 

IntelliJ is happy with my code.  So, I will run my program.

And here is our printout, 40 space 45 space 50 space 55, as expected here..

In this lecture you learned to use Java's 'while' statement.

Now, to practice what you learned, here is a coding exercise. 

// WHILE LOOP CODING EXERCISE:
// Implement a 'while' loop to print the four values,
// divisible by 3, less than or equal to 18

My name is Marius from AlefTav Coding.  Till our next meetup, KEEP CODING.

While Loop Example
06:12

Lecture 25
1 question

// Lecture 25: While Loop Solution

// WHILE LOOP CODING EXERCISE:
// Implement a ‘while’ loop with the control condition <= 18

// WHILE LOOP SOLUTION:
// while (j<=18)

// 9 12 15 18 

Hi there, My name is Marius from AlefTav Coding.  In this lecture I will provide the solution to the 'while' loop coding exercise. 

The problem statement reads 'Implement a ‘while’ loop with the control condition <= 18'.

In our expected solution we hava a 'while' loop as required.  The 'while' keyword is followed by 2 round brackets.  Inside these braces we place our condition which is to keep on looping until the value of 'j' is less than or equal to 18.  

To complete the program with we have a class 'Lecture25' with a method 'printWhileLoop'.  I have declared and initialized int value 'j' as 9.  Then deleting this 'todo' line and then typing this solution, 'while(j<=18)'.  Inside the code block are 2 lines of code.  The first is a print statement of each value of 'j' and added to that a space.  The second line is to add 3 to every  value as we iterate through the loop.  And stopping when the value of 'j' has reached this condition.

Again, to test our program I will comment out the method heading 'printWhileLoop' and uncomment the method header 'main'.  

The expected output should be as here, 1st value, 9 is divisible by 3 because 9 divide by 3 is 3.  Then a space.  And add 3 to 9 to get 12, add again a space and add 3 to get 15, space, add 3 to get 18.  These are the 4 values, divisible by 3, less than, these 3 or equal to, this one 18.

IntelliJ is happy that everything is in order.

Now I can run my code. And here is the expected output, 9 space, 12 space, 15 space and 18

In this lecture we looked at the solution to the while loop coding exercise. 
 
I am Marius from AlefTav Coding.  and until the next time, KEEP CODING.

While Loop Solution
04:07

// Lecture 26: Do-While Loop Example

// EXAMPLE PROBLEM STATEMENT:
// Implement a 'do-while' loop to print the 3 uppercase letters 'Q R S'

// EXAMPLE SOLUTION:
// do { System.out.print(letter+" "); letter++; } while (letter<='S');

// Q R S

Hi there, I am Marius from AlefTav Coding.  In this lecture you will learn how to use Java's 'do-while' statement. 

The 'do-while' loop is the third way that you can use in Java to deal with large amounts of information.  But, unlike the 'for' and the 'while' statements, with the 'do-while' loop the control test condition appears after the code block.
 
This problem statement requires us to implement 'do-while' and print the 3 uppercase letters Q R S, with a space between them.  And our expected output should look like this, 'Q R S'

Just as we saw with the 'for' loop and the 'while' loop, we again have 3 parts here with the 'do-while' loop.  The starting point is a declaration and initialization.  This is a statement before the loop.  The end-point is a statement after the loop, here.  Uppercase 'S' is where we stop according to this requirement.  The calculation from starting point to end-point occurs inside the code block, here, adding one to each letter to move to the next letter.

The keyword, 'do' is followed by a code block in curly braces.  Inside the code block I have 2 statements.  The 1st statement is to print the letter initialized before the code block, followed by adding a space.  The 2nd statement is to move to the next letter in the alphabet, uppercase letter, 'R'.  We say we do an 'increment'.  Then do a check to see if this letter is less than or equal to uppercase letter 'S'.  Since  uppercase 'R' is less than uppercase 'S' we go back into the code to print the letter 'R' and a space.  Then move to the next uppercase letter, 'S'.  Do a check.  Is 'S' less or equal to 'S'? Yes, then back into the loop to print the 'S' and a space.  Then move to the next letter, 'T'.  Do a check.  Is 'T' less than or equal to 'S'? no.  Then Java stops this loop. 

To complete my program.  I have a class, 'Lecture26' with a main method, and declaring and initializating dataType char storageName 'letter' assigned to uppercase letter 'Q'.  We have the keyword 'do' starting this loop.  Now inside the code block I remove the line comment and to print the current value of storageName 'letter' I type, 'System.out.print(letter + " ").  In the next line comment I type that Java must move on to the next letter 'letter++' I will comment this as 'Increment'

And after the code block the stop condition 'while letter <= 'S' ' and a semi-colon.
  
IntelliJ gives me the green tick mark to proceed to running my program.  And here is the expected. 

 
In this lecture you've learned to use Java's 'do-while' statement.

Now, on to this coding exercise. 

// DO-WHILE LOOP CODING EXERCISE:
// Implement a ‘do-while’ loop to print the 5 letters 
// ‘a’ to ‘e’ in reverse order
 

My name is Marius from AlefTav Coding.  Till next time, KEEP CODING.

Do-While Loop Example
06:17

Lecture 27
1 question

// Lecture 27: Do-While Loop Solution

// DO-WHILE LOOP CODING EXERCISE:
// Implement a ‘do-while’ loop to print the 5 letters 
// ‘a’ to ‘e’ in reverse order 

// DO-WHILE LOOP SOLUTION:
// while(letter>='a');

// e d c b a 

Hi there, My name is Marius from AlefTav Coding.  In this lecture we will review the solution to the 'do-while' loop coding exercise from the previous lecture. 

The problem statement asked you to implement a 'do-while' loop to print the 5 lowercase letters 'a' to 'e' in reverse order.

Our solution is the statement 'while in brackets storageName 'letter' is greater than or equal to letter a '

In our program, we have a class 'Lecture27' with a method 'printDoWhileLoop'.  Inside this method I have a declaration dataType char with storageName 'letter' initialized as lowercase letter 'e'.  Then a do-while loop with a print statement of each letter and a space added.  Then letter minus minus, meaning moving to the previous letter in the alphabet, which is lowercase letter 'd'.  This is known as 'Decrement'.  Then the code block closing brace after which I can type my solution, 'while (letter >= 'a');'

This 'while' test condition means to keep on going into the loop until we have reached letter 'a'  The code is 'while storageName 'letter' is greater than or equal to 'a'.  I have to say, equal to 'a', because I want letter 'a' to be printed as well.  The condition must appear inside these 2 round brackets.
And ending this 'while' statement with a semi-colon.

I want to test my program again, so I comment out the method heading 'printDoWhileLoop' and uncomment the method header 'main'.  Now I can run the program.  And I want to see the values 'e d c b a ' printed.  And, success, our program works correctly.  Let me comment and uncomment again.

In this lecture we reviewed the solution of the 'do-while' loop coding exercise. 
 
I am Marius from AlefTav Coding.  And, until we meet again in the next lecture, KEEP CODING.

Do-While Loop Solution
04:47
+
Arrays
4 Lectures 23:04

// Lecture 28: One-Dimensional Arrays Example

// EXAMPLE PROBLEM STATEMENT: 
// Implement a one-dimensional double array and 
// print all the values using a ‘for’ loop 

// EXAMPLE SOLUTION: 
// double[] numbers = {13.0, 17.0, 21.0, 25.0, 29.0};
// for (double number:numbers) {System.out.print(number+" ");}

// 13.0 17.0 21.0 25.0 29.0
 
Hi there, I am Marius from AlefTav Coding.  In this lecture you will learn how to implement a one-dimensional array in Java. 

Something that is one-dimensional has only one direction such as indicated by this arrow.  This is the image to bear in mind when you think about a one-dimensional array.
 
In Java, an array is a location area where a fixed number of values are stored.  All the values in an array must be the same dataType, and the length of an array is set when the array is initialized.
 
Now, for its internal structure.  An array is made up of 'elements'.  Here we have elements of dataType 'double', indicated by the dot in the numbers.  Each element has a set location in the array, called an 'index'.  Element 13.0 is stored at location 0, Element 17.0 is stored at location 1, Element 21.0, stored at location 2.  25.0 at location 3 and 29.0 at location 4.  The length of this array is 5, from index 0 to index 4 gives you 5 indices.

Lets now turn to IntelliJ.  Our problem statement says to 'Implement a one-dimensional double array and print all the values using a ‘for’ loop'.  The expected output should be, as here, 13.0 ... 29.0.
In our solution we declare a dataType 'double' and then to indicate an array I must add these square brackets after the 'double' dataType.  One set of square brackets because this is a one-dimensional array.  Then I name my array 'numbers' and do the intitialization.  Arrays are initialized inside curly braces, and then I list my elements, each element separated by a comma.

Now, I want to use the 'enhanced' 'for' loop.  Its syntax is as follows:  Declaration dataType 'double' and I will give the name 'number' then a colon and my array storageName 'numbers'.  This means storageName 'number' will go through this list of 'numbers' element by element.
Finally, the usual print statement with a space added after each element.

To complete my program,  I have a class 'Lecture28' with a method, 'main'.  I'll remove the one-line comment and implement the one-D array, 'double[] numbers = {13.0, 17.0, 21.0, 25.0, 29.0};'  Now, when I run my program, I want to see these values displayed.  And, so they are
 
In this lecture you learned to use Java's one-dimensional array.

Now, do this coding exercise. 

// ONE-DIMENSIONAL ARRAY CODING EXERCISE:
// Implement a one-dimensional integer array named ‘values’, 
// initialized with the elements 30, 31, 32 and 33

My name is Marius from AlefTav Coding.  Till next time, KEEP CODING.

One-Dimensional Arrays Example
06:35

Lecture 29
1 question

// Lecture 29: One-Dimensional Arrays Solution

// ONE-DIMENSIONAL ARRAY CODING EXERCISE:
// Implement a one-dimensional integer array named ‘values’, 
// initialized with the elements 30, 31, 32 and 33

// ONE-DIMENSIONAL ARRAY SOLUTION:
// int[] values = {30, 31, 32, 33};

// 30 31 32 33

Hi there, My name is Marius from AlefTav Coding.  In this lecture I will provide the solution to the one-dimensional array coding exercise. 

The problem statement reads 'Implement a one-dimensional integer array named ‘values’, initialized with the elements 30, 31, 32 and 33.

Our expected output is 30 31 32 33. 
You implement a one-dimensional integer array like this: dataType 'int' followed by one set of square brackets to indicate a one-dimensional array.  Then the storageName we are told must be, 'values'.  And initialized, curly braces inside of which these elements: 30 comma 31, 32, 33 and a semi-colon. 

Now, I want to complete my program.  It has a class, 'Lecture29' and this method, 'printOneDArray'.  Here is where I will type my solution...

To run the code, let me uncomment the method heading 'main' and comment the method header 'printOneDArray'.   I expect to see these four values.  And it is all good.

In this lecture we looked at the solution to the one-dimensional coding exercise. 
 
This is Marius from AlefTav Coding.  In the next lecture we will study two-dimensional arrays.  Until then, KEEP CODING.

One-Dimensional Arrays Solution
05:43

// Lecture 30: Two-Dimensional Arrays Example

// EXAMPLE PROBLEM STATEMENT: 
// Implement a two-dimensional String array 
// to print the element at row 1 column 3

// EXAMPLE SOLUTION:
// System.out.print(phoneticAlphabet[1][3]);

// india 
 
Hi there, this is Marius from AlefTav Coding.  In this lesson you will learn how to print one element of a two-dimensional array. 

Something that is two-dimensional has 2 different directions as can be seen here in this diagram.  We can think of a two-dimensional array as a table with rows and columns.  Here we have 4 rows, counting zero, one, two and three.   And 5 columns counting zero, one, two, three and four.  In programming we start counting from zero.  Lets assume that in this table I want to print the word stored at row 1, column 3, which is the word, 'india',

Now, in IntelliJ our problem statement says 'Implement a 2D String array to print the element at row 1 and column 3'.  As we saw in the diagram the expected output is the word, 'india', here.  

In my program, there is a class, 'Lecture30' with a 'main' method.  My declaration is String array array phoneticAlphabet.  These 2 sets of square brackets indicate a two-dimensional array.  dataType and storageName.  Here is the initialization with these outer curly braces.  In the inner curly braces I have rows and columns.  Lets highlight the rows: row 0 and row.  Then the columns: column zero, column one, 2 and column 3.  And there is the element we want.  

Now, looking at the solution:  a print statement and in the round brackets the storageName, 'phoneticAlphabet' with 'one' in the first square brackets, representing the rows.  Then 'three' in the second square brackets, representing the columns.

Let me type my solution in the comment line System.out.print(phoneticAlphabet[1][3]);
The green tick mark from IntelliJ indicates I can run the program.  And I want to see here this word, 'india'
And there it is.

 
In this lecture you've learned how to print one element from a two-dimensional array in Java.

Now, for the homework practice, here is the coding exercise of this lecture. 

// TWO-DIMENSIONAL ARRAYS CODING EXERCISE:
// Implement a two-dimensional String array 
// to print the element at row 0 column 4

My name is Marius from AlefTav Coding.  Till next time, KEEP CODING.

Two-Dimensional Arrays Example
06:27

Lecture 31
1 question

// Lecture 31: Two-Dimensional Arrays Solution

// TWO-DIMENSIONAL ARRAYS PART 1 CODING EXERCISE:
// Implement a two-dimensional String array 
// to print the element at row 0 column 4 

// TWO-DIMENSIONAL ARRAYS PART 1 SOLUTION:
// System.out.print(countries[0][4]);

// Austria

Hi there, I am Marius from AlefTav Coding.  In this lecture I will provide the solution to the two-dimensional arrays coding exercise. 

The problem statement says 'Implement a two-dimensional String array to print the element at row 0 and column 4'.

Our program has a class, 'Lecture31' with a method, 'printTwoDArray'.  Then we have declared String array array countries initialized as this list of country names. So, we have here a two-dimensional String array.  You were asked to print the element at row 0, column 4.

Lets highlight the rows and columns.  Row zero, then column zero, column one, column two, three and four.  So, we want to see printed out this country, 'Austria'.

The solution here is a print statement with our storageName, 'countries' and the first index, zero, between square brackets and the second index, four, between square brackets.

Now, I will type this solution in this comment line...  
And I can now do the usual uncomment of 'main' and comment of this method.  If IntelliJ is happy I can then run my code.  You want to see the country name 'Austria' appearing here.  And success.

In this lecture we reviewed the solution to the 2-dimensional coding exercise. 
 
I am Marius from AlefTav Coding.  Until next time, KEEP CODING.

Two-Dimensional Arrays Solution
04:19
+
Exceptions
2 Lectures 10:21

// Lecture 32: Exceptions Example

// EXAMPLE PROBLEM STATEMENT: 
// Implement an IllegalArgumentException to be thrown 
// when a String named 'theDate' is not 10 characters

// EXAMPLE SOLUTION:
// throw new IllegalArgumentException("Date must be 10 characters long");

// Date must be 10 characters long
 
Hi there, I am Marius from AlefTav Coding.  In this lecture you will learn how to use exceptions in Java. 

An 'exception' is something that stops your Java program working correctly.

When you run your program, this is the flow of events you want to see happen.  However, as a programmer, you know that this almost never happens.
Instead, this is what you see happening in your Java program.  This is an exceptional event or an 'exception'. 

So, you have to find a way to bypass this 'exception', in order for your program to continue working.
When we do this, we say that we 'throw' an exception.

Now to our code.  This problem statement says 'Implement an 'IllegalArgumentException' to be thrown when a String named 'theDate' is not initialized to 10 characters' in length.

The expected output should be printing this error message, 'Date must be 10 characters long'.  

Lets look at our program.  We have a class, 'Lecture32' with a 'main' method.  Then we have a declaration, 'String theDate', initialized as '2017-04-21'.  The 21st of April 2017 in this format.  Now, I want to put some code here to test if 'theDate' is actually initialized with the correct number of characters.  I will do this checking by using an 'if' statement.  If the number of characters here is not equal to 10, then I want to display an error message.  This message is to 'throw' a new dataType named 'IllegalArgumentException'.  The error message to be displayed appears between these two round brackets.

Now, let me type this solution by removing these line comments...
  
IntelliJ says all is fine. But, before I run the program I will remove the last character here so that now there are only 9 characters here, 1, 2, ... 9 characters.  This means that when I run the code Java will discover that the required 10 characters are not there and will therefore display this error message in my output window.
On to running my program.  And there the expected error message, displayed in red indicating I have properly handled an exception.

In this lecture you've learned how to use Java's IllegalArgumentException exception operation.

Now, on to the homework, which is this coding exercise. 

// EXCEPTIONS CODING EXERCISE:
// Implement an IllegalArgumentException to be thrown 
// when an int named 'age' is a negative number

My name is Marius from AlefTav Coding.  Till next time, KEEP CODING.

Exceptions Example
06:08

Lecture 33
1 question

// Lecture 33: Exceptions Solution

// EXCEPTIONS CODING EXERCISE:
// Implement an IllegalArgumentException to be thrown 
// when an int named 'age' is a negative number

// EXCEPTIONS SOLUTION:
// throw new IllegalArgumentException("Age must be a positive number");

// Age must be a positive number

Hi there, I am Marius from AlefTav Coding.  In this lecture you will learn the solution to the éxceptions coding exercise. 

The problem statement reads 'Implement an IllegalArgumentException to be thrown when an int named 'age' is a negative number'.

The expected output should be this error message displayed to the user, that the storageName 'Age must be a positive number'.

Our solution is here.  To implement an 'IllegalArgumentException' means to handle some error in our code.  Here we use the 'throw' keyword, followed by another keyword, 'new' and the type of mistake, an 'IllegalArgumentException'.  Then inside these 2 round braces, you say what the error message is that you want to be displayed, that the 'Age must be a positive number'.

Let's complete our program.  Our class is 'Lecture33' with a method, 'main'.  I have declared an int 'age' initialized as minus 5, a negative value.  Then I have a test, if storageName 'age' is less than or equal to zero, Java must display an error message.  Here in this comment line is where I will type our solution...
Now, on to running my code.  'age' here is assigned a negative value, so therefore in testing my program, I will see this error message appear.  And there it is.

In this lecture you've learnt the solution to the exceptions coding exercise. 
 
My name is Marius from AlefTav Coding.  In the remainder of this course we will study classes and objects; the features that are at the heart of Java, the language.  Until then, KEEP CODING.

Exceptions Solution
04:13
+
Java classes
20 Lectures 01:47:22

// Lecture 34: Java Classes Example

// EXAMPLE PROBLEM STATEMENT: 
// Create a Java class for this lecture

// EXAMPLE SOLUTION:
// public class Lecture34 {}

// ...
 
Hi there, I am Marius from AlefTav Coding.  In this lecture you will learn how to create a class in Java. 

What is a 'class'?  It is a general idea of something, anything, existing in the real world.  For example, this course of study.

In this and the following lectures we will use this course, 'Java 8 for Complete Beginners' to explain various concepts and terms.   The examples from now on will be about a certain aspect of this course.  And you will learn the Java code to write when you model that aspect of this course.

The example problem here is to 'Create a Java class for this lecture'.  There is no expected output here, because the class, for now, will not have any code to run.  We say, the class does not have 'functionality'.

You start with the keyword, 'public', meaning this class is accessible from anywhere, and all lowercase letters.  This lecture is lecture number 34 of this course.  In order for you to make it a 'class', type the keyword, 'class'.  Again, being a keyword, it is all lowercase.  Then,  the class name, 'Lecture34'.  The first letter of a Java class name must be uppercase.  And, if the class name is made up of more than one word, you don't leave any spaces in the name. 
Then you have 2 curly braces.  And inside them is where you type the code for your class.

I will not run this class because there isn't any code that can be tested by running the program.  So, here we have the basic structure of a Java class.

public class Lecture34 {

}

In this lecture you have learnt how to create a Java class.

The homework for this lecture is not a coding exercise, and it should take you 15 seconds to complete.  Just write down your answer on a piece of paper.

// JAVA CLASSES HOMEWORK:
// Create a Java class named 'course'

My name is Marius from AlefTav Coding.  Till our next meeting, KEEP CODING.

Java Classes Example
05:10

Lecture 35
1 question

// Lecture 35: Java Classes Solution

// JAVA CLASSES HOMEWORK:
// Create a Java class named 'course'

// JAVA CLASSES SOLUTION:
// public class Course {}

// ...

Hallo there, I am Marius from AlefTav Coding.  In this lecture you will learn the solution to the java classes homework. 

The problem statement reads, 'Create a Java class named 'course'.

There is no expected output because, as indicated in the last lecture, we don't have any code inside the class that can be tested.
Also, this homework did not require a coding exercise.  You only had to write down 2 lines of Java code on a piece of paper.

Looking at the solution, you start with the keyword 'public', all lowercase, to make the class accessible from anywhere.  Then, to create a Java class you write the keyword, 'class', all lowercase again.  This is followed by the name you want to give your class.  In this case, it is 'Course'.  Uppercase first letter, because Java classes start with an uppercase letter.  Then, two curly braces within which the code for this class will be written.  

Now, let me type the solution in this file, 'public class Course {}'

And that is it for this homework.

In this lecture you learnt the solution to the java classes exercise. 
 
My name is Marius from AlefTav Coding.  Until next time, when we'll continue looking at classes, KEEP CODING.

Java Classes Solution
03:49

// Lecture 36: Java Fields Example

// EXAMPLE PROBLEM STATEMENT: 
// Declare an int 'field' named 'lectureNumber', initialized as 36
// and print it out

// EXAMPLE SOLUTION:
// int lectureNumber = 36;  System.out.print(lectureNumber);

// 36
 
Hi there, my name is Marius from AlefTav Coding.  In this lecture you will learn to use 'fields' in Java. 

A 'field' is a characteristic of a Java class.  For example, one of the characteristics of this lecture is that it has a number by which it can be identified. 
You already used 'fields' in previous lectures.  It is only that now, and in the following lectures, we will be introducing the proper Java terms for the various features that relate to classes and objects. 

Let's look at this problem statement.  We must 'Declare a int field, named 'lectureNumber', initialized as 36 and print it out'.  Our expected output, here, must be the number 36, which is the number of this lecture.

In the solution, we have a dataType, 'int', as required here.  The storageName is 'lectureNumber', this second requirement.  Then equals or assigned to 36, the instruction here.  This is followed by a print statement of the storageName, 'lectureNumber'.  And semi-colons to end the statements.

Our program has a class, 'Lecture36' with a 'main' method.  I will remove the line comments and type our solution.  First the declaration and initialization.  I'll comment this as 'field'.  Then, finally I type the print statement.

IntelliJ says everything is fine.  Now, I run my program, and I want to see the number 36 here.  And success.

 
In this lecture you learned how to implement a 'field' in Java.

Now, please do this coding exercise.

// JAVA FIELDS CODING EXERCISE:
// Declare a boolean 'field' named 'isLectureCompleted',
// initialized as 'true'

I am Marius from AlefTav Coding.  Till we meet again in the next lecture, KEEP CODING.

Java Fields Example
04:00

Lecture 37
1 question

// Lecture 37: Java Fields Solution

// JAVA FIELDS CODING EXERCISE:
// Declare a boolean 'field' named 'isLectureCompleted',
// initialized as 'true'

// JAVA FIELDS SOLUTION:
// boolean isLectureCompleted = true;

// true

Hallo there, I am Marius from AlefTav Coding.  In this lecture I will provide the solution to the java 'fields' coding exercise. 

The problem statement reads 'Declare a boolean 'field' named 'isLectureCompleted', initialized as 'true'

When I run this code I expect to see a printout, 'true', as here.

Now, in the solution, I have a boolean dataType, from this requirement, then 'isLectureCompleted' the field or storageName, equals or initialized as the value 'true' and a semi-colon.

Our program has a class, 'Lecture37' with a 'main' method and a print statement of the field, 'isLectureCompleted'.
Let me delete these line comments and type my solution ...

Then, checking to see what IntelliJ says.  It is happy.  So, I run my code, and as expected, I see the printout, 'true'.
Success, it is 'true' that you have now completed this lesson.

In this lecture we reviewed the solution to the java 'fields' coding exercise. 
 
My name is Marius from AlefTav Coding.  Until next time, when we'll look at Java 'objects', KEEP CODING.

Java Fields Solution
02:56

// Lecture 38: Java Objects Example

// EXAMPLE PROBLEM STATEMENT: 
// Create an object named 'course1' of dataType 'Course'
// and print its dataType

// EXAMPLE SOLUTION:
// Course course1 = new Course();  System.out.print(course1.getClass() );

// class Course
 
Hi there, I am Marius from AlefTav Coding.  In this lecture you will learn to implement an 'object' in Java. 

Now, while a 'class' is a general idea of something, as we saw in an earlier lecture, an 'object' is more specific.  For example, there are many different study courses available for you to try out.  We can simplify all these available courses by creating or modelling a Java 'class', like this, 'public class Course {}'.  This piece of code is a Java model of any course of study.

But, you have chosen to study this particular course.  The one you are watching now, 'Java 8 for Complete Beginners'.  In Java you can create an 'object' to refer to one specific course.  So, how do you create such an object?  As always, in Java you follow the pattern: declaration, then initialization.  Which is 'dataType' followed by 'storageName' followed by assigning to a value.  The dataType here is the class name 'Course', the storageName is one you make up, let's say 'course1', then the equals symbol for assigning.  Then, to actually create the object, in Java, you write the keyword, 'new' followed by the name of the class, then 2 round braces and the semi-colon to end the statement.  Here, you have created an object.

In IntelliJ we have this problem statement, 'Create an object named 'course1', of dataType 'Course' and print the dataType'.  

Our output, here is to print the dataType, which is a 'class' that has the name, 'Course'. We have just seen how to create a Java 'object'.  And in the solution we have, dataType, 'Course' storageName, 'course1' assigned to a new object of this class type. 

Then, in order to display something on screen, in Java you type a print statement.  This is our final requirement, to print the dataType of this object.  Because we have created an object of this class, when do the print we should see the name of this same class, here.  In Java you use the 'dot' notation like this, name of object dot and to have Java tell you what the name of the class is we can type the method, 'getClass()' with these 2 round brackets.

Now, lets complete our program.  Our class is 'Lecture38' and this method is 'main'.  Here, in another file, I have created a class, 'Course'.  I can now create an object, ... and then type the print statement.
 
IntelliJ says everything is ok.  Now, I run my program, and I want to see this text appearing in the output window.  And so it is.

 
In this lecture you've learned how to create a Java 'object' and print its dataType.

Now, this coding exercise for the homework.

// JAVA OBJECTS CODING EXERCISE:
// Create an object named ‘program1’ of dataType ‘Program’

I am Marius from AlefTav Coding.  Until our next meeting, KEEP CODING.

Objects Example
07:06

Lecture 39
1 question

// Lecture 39: Java Objects Solution

// JAVA OBJECTS CODING EXERCISE:
// Create an object named ‘program1’ of dataType ‘Program’

// JAVA OBJECTS SOLUTION:
// Program program1 = new Program();

// class Program

Hallo there, I am Marius from AlefTav Coding.  In this lecture you will learn the solution to the java 'objects' coding exercise. 

The problem statement reads, 'Create an object named ‘program1’, of dataType ‘Program’

Here, in the solution, we have a declaration, dataType 'Program' followed by storageName, 'program1'.  The class name 'Program' has an uppercase first letter here, while the object 'program1' starts with a lowercase letter, here.  Then, I assign the reference 'program1' to a 'new' object of type 'Program' followed by these 2 round brackets and ending the statement with a semi-colon.

Let me complete our code.  Here is a class, 'Lecture39' and one method, 'main'.  Then, I have here a print statement to display the dataType after creating the object. Then, in another file, here, is the declaration of the class, 'Program'.  In my main method, I will now delete this comment to type this line of code where I create a 'Program' object... 

My code is given the all-clear, here and when I run the code, I want to see the dataType, 'Program'.  
Yes, it is all good.

In this lecture you learnt the solution to the java 'objects' coding exercise. 
 
My name is Marius from AlefTav Coding.  Next time, we will look at Java 'methods'.  Till then, KEEP CODING.

Objects Solution
03:45

// Lecture 40: Java Methods Example

// EXAMPLE PROBLEM STATEMENT: 
// Declare a method named 'printSkillLevel' 

// EXAMPLE SOLUTION:
// public void printSkillLevel()

// This course is for java beginners
 
Hi there, this is Marius from AlefTav Coding.  In this lecture you will learn to implement a 'method' in Java. 

A 'method' is some action that is to be performed.  The name of a 'method' gives an indication of exactly what type of action.  

Let's look at the different parts of a method.  Firstly, here is the keyword 'public' indicating this method can be accessed from anywhere.  Then, another keyword, 'void' means this method does not produce a calculation that can be passed to another method.  
This is followed by the name of the method, which you make up, and starts with a lowercase letter.  Here, 'printSkillLevel' tells us that this method will display information about the skills needed to study this course, 'Java 8 for Beginners'.  The method name must be followed by 2 round brackets.  Then, the 2 curly braces inside of which the code for the method will be typed.  Here, we have a print statement.  The action that this method produces is to display this code in quotation marks.

Turning now to IntelliJ, the problem statement for this lecture requires us to 'Declare a method named 'printSkillLevel'.
Our output is to display this line of code.  In the solution we have the method heading, 'public void printSkillLevel()

Now to our program.  We have in this file a class, 'Lecture40' with a 'main' method.  Inside of main we have created a reference, 'course1', to a new object of type 'Course'.  Now that we have created an object we can use the one method that appears in this class 'Course'.  How we do this is by using the 'dot' notation. object reference, 'course1' dot method name, 'printSkillLevel' round brackets and semi-colon.
In another file, we have the class, 'Course' with one method that has a print statement.  Now I can type this solution by deleting this line comment, 'public void printSkillLevel()'
Back in my main program, I see that IntelliJ is happy.  We run the program, and the expected output is this text. And there it is.

I created an object of type 'Course' to 'call' this method in that class.  The result is the execution of the code in that method, which is this output.
 
In this lecture you've learned how to create and run a Java 'method'.

Now, for the coding exercise as the homework.

// JAVA METHODS CODING EXERCISE:
// Declare a method named 'printNumberOfCodingExercises' 

I am Marius from AlefTav Coding.  Until we meet again in the next lecture, KEEP CODING.

Methods Example
06:12

Lecture 41
1 question

// Lecture 41: Java Methods Solution

// JAVA METHODS CODING EXERCISE:
// Declare a method named 'printNumberOfCodingExercises' 

// JAVA METHODS SOLUTION:
// public void printNumberOfCodingExercises()

// This course has 24 coding exercises

Hi there, My name is Marius from AlefTav Coding.  In this lecture you will learn the solution to the coding exercise about 'methods'. 

The problem statement reads 'Declare a method named 'printNumberOfCodingExercises'

The output when running the program is the text, 'This course has 24 coding exercises'.

In our solution we have the method header 'public void', and the method name, 'printNumberOfCodingExercises', followed by 2 round brackets.  

Now, we can complete the program.  In the main file, we have a class 'Lecture41' with a method 'main'.  In 'main' I have created an object of type 'Course', with the name, 'course1'.  My object calls the method, 'printNumberOfCodingExercises'.  And this method exists inside the class, 'Course'.

Let me turn to this file with the class, 'Course'.   In here is where I need to type my solution... Back in my main program, I see that IntelliJ is happy. 

Before running the code lets recap:  A Java method is a piece of code that you find inside a class.  The method itself contains some activity.  So, if you as a Java programmer want to do something you create a method to carry out the activity you want to perform.  The procedure is as follows:

step 1. You create a class - 'public class Course'
step 2. You create a method inside that class - 'public void printNumberOfCodingExercises()'
step 3. You create an object of your class - 'Course course1 = new Course();'
finally, step 4. Your object 'calls' the method using the dot notation - 'course1.printNumberOfCodingExercises();'

Now, let me run my code.  And I want to see this line of code printed, 'This course has 24 coding exercises'.  Success

In this lecture you learnt the solution to the java 'methods' coding exercise. 
 
This is Marius from AlefTav Coding.  In the next lecture, we will look at 'parameters'.  Till then, KEEP CODING.

Methods Solution
05:13

// Lecture 42: Parameters Example

// EXAMPLE PROBLEM STATEMENT:
// Implement a method, 'setJavaVersion' that receives
// one parameter, a String named 'version'

// EXAMPLE SOLUTION:
// public void setJavaVersion(String version)

// Java 8
 
Hi there, this is Marius from AlefTav Coding.  In this lecture you will learn how to implement 'parameters' in Java. 

'Parameters' are the items that appear inside the 2 round brackets after the name of a method.  Here we have a method, 'setJavaVersion'.  One or more parameter can be added inside these 2 round braces.  Such as the declaration here.  We say, this method expects to receive one 'parameter'.  The dataType of this parameter is String, and I have made up a storageName, 'version'. 

Turning now to IntelliJ.  This lecture's problem statement reads, 'Implement a method, 'setJavaVersion' that receives one parameter, a String named, 'version'.  My aim here is to create a method that prints 'Java 8', the version of Java that I am using in these tutorials, my expected output here.  How do you do this?  Well, you create a method as we see in the example solution.  The method header is 'public', 'void' and the method name, 'setJavaVersion'.  For the parameter you follow the Java pattern of a declaration, dataType, String followed by storageName 'version', inside the 2 round brackets.

Next, in our main program, I have a class, 'Lecture42' with a main method.  Inside here I have created an object of dataType 'Course'.  Then my object calls the method, 'setJavaVersion' which is inside the class 'Course'.  Now, since this method, 'setJavaVersion' expects to receive a String when you call it, according to this requirement, you must to give it a String.  And, as I said earlier, I am using Java 8.  So, this is the String I must give to that method.  We say that we 'pass' in a String as argument to the method, 'setJavaVersion'

On to this other file where the class, 'Course' is located.  It is in this class where you need to implement this solution.  So, I type, 'public void setJavaVersion(String version).  This method contains a print statement that displays this String received by it.
 
Back in my main program, I see that IntelliJ is happy.  So, I will test my program, click run and I expect to see printed the Java version used in this course.  Which is 'Java 8' 
And as expected here.

 
In this lecture you've learned to use parameters.

Now, to practice what you learned, here is the coding exercise for this lecture. 

// PARAMETERS CODING EXERCISE:
// Implement a method, 'setStudentLocations' that receives
// one parameter, a String named 'locations'

My name is Marius from AlefTav Coding.  Till next time, KEEP CODING.

Parameters Example
05:41

Lecture 43
1 question

// Lecture 43: Parameters Solution

// PARAMETERS CODING EXERCISE:
// Implement a method, 'setStudentLocations' that receives
// one parameter, a String named 'locations'

// PARAMETERS SOLUTION:
// public void setStudentLocations(String locations)

// worldwide 

Hi there, I am Marius from AlefTav Coding.  In this lecture you will learn the solution to the parameters coding exercise. 

The problem statement reads 'Implement a method 'setStudentLocations' that receives one parameter, a String named, 'locations' 

I expect to see printed the text, 'worldwide'.  In other words, the students for this course are found all round the world.

My solution is 'public void, method name 'setStudentLocations' and parameter, dataType 'String' with storageName 'locations'.

In our main file we have a class, 'Lecture43' which has a main method.  In this method I created an object in this line.  In the next line the object calls the method, 'setStudentLocations'.   Because this method expects to receive a String, I pass in as argument the text, 'worldwide'.
Now, on to this file where I have the class, 'Course'.  This class has a method that prints the String 'locations'.  And it is here where I have to implement as a method header this solution.  So, I will type, 'public void setStudentLocations(String locations)'.   

Going back to our main program, I notice that IntelliJ gives me the all clear.  Let me test the program by running it.

And here is the expected output, all correct.  Indeed, the students for this course are found worldwide.

In this lecture you learned the solution to the parameters coding exercise. 
 
I am Marius from AlefTav Coding.  And until next time, KEEP CODING.

Parameters Solution
04:14

// Lecture 44: Method Overloading Example

// EXAMPLE PROBLEM STATEMENT:
// Implement method overloading, with 2 methods named 'printCoursePrice'.
// The one method receives a String parameter and the other an int parameter.

// EXAMPLE SOLUTION:
// public void printCoursePrice(String value)
// public void printCoursePrice(int number)

// two hundred 200
 
Hi there, I am Marius from AlefTav Coding.  In this lecture you will learn how to implement 'method overloading' in Java. 

'Method overloading' is where you have methods with the same name, but with different parameters.

Here is a method, 'printCoursePrice' that expects to receives one parameter of type 'String'.  Here is another method of the same name, 'printCoursePrice'.  But this second method is waiting to receive an int parameter.

Lets look at our problem statement, 'Implement method overloading, with 2 methods named 'printCoursePrice'.  The one method receives a String parameter and the other an int parameter'

Our expected output is a String of text, 'two hundred' in words and an integer number, '200'.

In the solution we have implemented 2 method headers.  The first one is, 'public void printCoursePrice with a String parameter, named 'value'.  And the second one is, again, 'printCoursePrice'.  This time it receives an int parameter with the name 'number'.  This is 'method overloading', separate methods that have the same name, but with different parameters.

Again, in our main file we have a class, 'Lecture44' with a main method in which we have created an object.  This object calls the method, 'printCoursePrice'.  The first time this method is called we pass in as argument the words, 'two hundred' as text.  This is for the method of this name that expects to receive a String.  When we call this method a second time we pass in 200 as a number.  This time for the method that expects to receive an integer. 

Now, to this file where we have located the class 'Course'.  This class has 2 methods.  The first method prints a String, 'value' and the second method prints an int, 'number'.  I need to delete the one line comment and type my solutions as method headers.  First the method that receives a String...  Then the method that receives an int. 

Turning back to my main program.  IntelliJ says everything is fine.  Then, I can run my program to test it, and I want to see printed these two words followed by a space and this number.  And we are happy, because it is as expected here.

 
In this lecture you've learned to use method overloading.

Now, to practice what you have learned, here is the coding exercise for this lecture. 

// METHOD OVERLOADING CODING EXERCISE:
// Implement method overloading, with 2 methods named 'printNumberOfLectures'.
// The one method receives an int parameter and the other a String parameter.

I am Marius from AlefTav Coding.  Till our next meetup, KEEP CODING.

Method overloading Example
06:41

Lecture 45
1 question

// Lecture 45: Method Overloading Solution

// METHOD OVERLOADING CODING EXERCISE:
// Implement method overloading, with 2 methods named 'printNumberOfLectures'.
// The one method receives an int parameter and the other a String parameter.

// METHOD OVERLOADING SOLUTION:
// public void printNumberOfLectures(int number) 
// public void printNumberOfLectures(String value)

// 54 fifty four 

Hi, This is Marius from AlefTav Coding.  In this lecture you will learn the solution to the method overloading coding exercise. 

The problem statement reads 'Implement method overloading, with 2 methods named 'printNumberOfLectures'.  The one method receives an int parameter and the other a String parameter.

Here in our solution we have 2 method headings.  The first is 'public void printNumberOfLectures' with an int parameter.  And I am giving it the name 'number'.  Then, a second method header, 'public void' As per this requirement, this method also has the name, 'printNumberOfLectures'.  But the parameter here has the dataType, String.  And the name given to it is 'value'

In my main program, I have a class, 'Lecture45' with a main method.  And I have created an object here.  Now I call the first method, 'printNumberOfLectures'.  Since this method expects to receive an int, I pass in as an argument, the number 54, which is the number of lectures in this course.
Next, I call the method 'printNumberOfLectures' again.  But the second method expects a string.  So, I pass in the text, 'fifty four' in words.

In this other file is my class, 'Course' with 2 methods.  The one method prints a number and the other method, a String.  Let me implement this solution by removing the line comments, first here... and then here... 

Let me check IntelliJ's verdict.  It gives me the OK.  Now, to test my code, I will run it.

My expected solution, here is the number, 54 followed by a space and then the words 'fifty four' The single space here is at the beginning of this string. Comparing the actual printout with this expected output, And we have achieved success.

In this lecture you learnt the solution to the method overloading coding exercise. 
 
I am Marius from AlefTav Coding.  In the next lecture you will learn about Java's static modifier.  Till then, KEEP CODING.

Method overloading Solution
05:43

// Lecture 46: Static Modifier Example

// EXAMPLE PROBLEM STATEMENT: 
// Implement the 'static' modifier to declare a String named 'languageOfInstruction'. 
// Initialize and print it as 'English'

// EXAMPLE SOLUTION: 
// Course.languageOfInstruction = "English"; 
// static String languageOfInstruction;

// English

Hi there, this is Marius from AlefTav Coding.  In this lecture you will learn how to implement the 'static' modifier in Java.

The term 'static' refers to a 'class' as opposed to an 'object' of that class.  For this reason it is also known as a class member.  This means you access the member through the class, rather than through an object of that class.  Therefore, when implementing a 'static' modifier, you don't create an object.  That is you don't write a statement with the keyword, 'new'.
You create a 'static' member by writing the keyword, 'static' before the field name or the method name.

Let us study the code on the slides, before we do live coding in IntelliJ.
I want to use a static modifier to print the language of instruction that I use in this course, which is 'English'.  We again have our class, 'Course'.  And we have a field String 'languageOfInstruction'.  (As you know by now, the pattern in Java is that before you can use a member, you first have to declare it.)  Now, I want to tell Java that I am going to access this field through the class, and not through an object of that class.  For this purpose I add the Java keyword, 'static' in front of this field.  Because the field, 'languageOfInstruction' is 'static' I can now access it via my class, 'Course'.  
Here, in my main program, I call 'languageOfInstruction' and assign the language of the course as a String.  (Again, following the Java pattern, that, after a member is declared, it must then be initialized).  Then, I do a print statement, And the language of this course, 'English' is printed.

Now, in IntelliJ, the problem statement says, 'Implement the static modifier to declare a String named 'languageOfInstruction'.  Initialize and print it as 'English'.  The expected output here must be this word, 'English'.  My solution is as follows:  In the main method, I access the field, 'languageOfInstruction' through the class, 'Course', in this declaration.  And I initialize it at the same time.  Then in the class, 'Course' I implement the static code as a declaration, 'static String languageOfInstruction'.

This file has a class, 'Lecture46' with a main method.  Here, I will remove the line comment and type the code to access the static modifier and initialize it, 'Course.languageOfInstruction = 'English'.  Then, here is a print statement to display the value just initialized.

I move on to this file with the class, 'Course'.  And here I declare the static modifier field, 'static String languageOfInstruction;'.

Finally, turning back to my main program, a check to see that I can proceed to run the program.  The language of instruction should be printed as, 'English'.  And there it is just as expected.

 
In this lecture you learned to use Java's static modifier.

Now, to practice what you learned, here is this lecture's coding exercise. 

// STATIC MODIFIER CODING EXERCISE:
// Implement the 'static' modifier to declare an int named 'coursePrice'. 

I am Marius from AlefTav Coding.  See you in next video when we will be looking at the solution to this problem statement.  Until then, KEEP CODING.

Static modifier Example
06:49

Lecture 47
1 question

// Lecture 47: Static Modifier Solution

// STATIC MODIFIER CODING EXERCISE:
// Implement the 'static' modifier to declare an int named 'coursePrice'. 

// STATIC MODIFIER SOLUTION:
// static int coursePrice; // Declaration

// 200

Hi there, I am Marius from AlefTav Coding.  In this lecture you will learn the solution to the static modifier coding exercise. 

The problem statement says, 'Implement the 'static' modifier to declare an int named 'coursePrice'.  

The expected output here is the price of this course, 200.

And here is my solution.  To specify that this field is to be accessed through the class,  you type the keyword, 'static'.  Then you do the usual declaration dataType 'int' and storageName 'coursePrice'.  This declaration must appear in the class, 'Course'.  

This file has a class, 'Lecture47' with a main method.  Here we declare a static field, accessed via the class, and initialize it.  This is followed by printing out the initialized value, to test the code.

In this second file is the class, 'Course'.  In here is where I must implement my solution, 'static int coursePrice;'
 
And back in my main program, IntelliJ gives me the ok here.  I can now run my code, and I expect to this output, the course price of 200 to be displayed here. Yay!, we are successful.

In this lecture you have learned the solution to the static modifier coding exercise. 
 
This is Marius from AlefTav Coding.  In the next lecture you will learn about 'anonymous' classes.  Until then, KEEP CODING.

Static modifier Solution
03:23

// Lecture 48: Anonymous Classes Example

// EXAMPLE PROBLEM STATEMENT: 
// Implement an 'anonymous' class by overriding the method 'getCourseName' 

// EXAMPLE SOLUTION: 
// { @Override public void getCourseName() {
// System.out.print("Java 8 for Complete Beginners");} }

// Java for all
// Java 8 for Complete Beginners

Hi, there, this is Marius from AlefTav Coding.  In this lecture you will learn how to implement anonymous classes in Java.

An anonymous class is a class inside another class.  It does not have a name, therefore the term, 'anonymous'.  You use an anonymous class if you need to implement a class only once.

Let's see how it works.  We have again here a class 'Course'.  It has one method, 'getCourseName' that prints the text, 'Java for all'.  
In the main program you create an object with the name, 'course1'.  And when you call the method, 'getCourseName', you get this printout 'Java for all'.  

Let's say, that at some future date you want to update the information contained in this method.  But you don't want to change the code in that method or go to the trouble of creating a new class with a method of the same name.  What you can do is to create an anonymous class to print the update information.  And you create it at the same place in your code where you created the original object.  

In your main method you type a code block before the semi-colon of the statement where you created the object.  Inside there you write a second method with the name, 'getCourseName'.  This is the same method name as the one in the class 'Course'.  So, you have to tell Java that you want to update the information in the first method.  Doing so in Java is to do an 'override' with the '@' sign before the word, 'Override'.  The code you are writing in this method is the update course name, 'Java 8 for Complete Beginners'.  And this is what gets printed when you call the method.  Here you have created a new class without a name.

Lets now turn to IntelliJ. The problem statement reads, 'Implement an 'anonymous' class by overriding the method 'getCourseName'.  We want to first output the code from the original method, this line.  Then, after implementing the anonymous class, we want to print the new course name, 'Java 8 for Complete Beginners'.  

The solution is this code in the main program.  Inside the code block of these curly braces, you override the method, 'getCourseName' with the updated course name displayed.

In the main file there is a class 'Lecture48' with a main method, inside of which I have created an object.  The object calls this first method.  And, when I run the code I see printed the old course name, 'Java for all'.   

Now, I implement an anonymous class.  Before the semi-colon you type a code block with 2 curly braces.  You override the first method with '@Override public void getCourseName() { System.out.print("Java 8 for Complete Beginners"); }.  Running the program again, you will see the updated course name.  And there it is.
 
In this lecture you learnt to implement an anonymous class.

Now, to re-inforce what you have learned, do this coding exercise. 

// ANONYMOUS CLASS CODING EXERCISE:
// Implement an 'anonymous' class by overriding the method named 'isLive' 
 
I am Marius from AlefTav Coding.  See you in the next video and, as always, KEEP CODING.

Anonymous classes Example
07:49

Lecture 49
1 question

// Lecture 49: Anonymous Classes Solution

// ANONYMOUS CLASSES CODING EXERCISE:
// Implement an 'anonymous' class by overriding the method named 'isLive'

// ANONYMOUS CLASSES SOLUTION:
// @Override public void isLive() 

// Java 8 for Complete Beginners is live

Hi there, This is Marius from AlefTav Coding.  In this lecture you will learn the solution to the anonymous class coding exercise. 

The problem statement says 'Implement an 'anonymous' class by overriding the method named 'isLive'.  

Here is the solution, to do override with '@Override' and then the method header, 'public void isLive()'

Lets have a look at this file where you have a class, 'Lecture49' with a main method.  In main we have again created a new object with the name, 'course1'.  Here, you use this object to call the method, 'isLive'.  And we find 'isLive' in this other file inside this class 'Course'.  As you can see the method, here.  'isLive' has a statement that prints the text, 'The course is live'.  
Before implementing the anonymous class solution, let me run my program to test that the original method, this line of code, is displayed.  In main, I will comment out this entire coding block with the block comment, the /* */ symbols.  Now, when you run the program you see the code from the original method.

Let me remove the block comment here and here and the semi-colon at the line where I created the object.  Now, removing the 'todo' comment and typing the solution in the main method.  Just the method heading of the anonymous class, '@Override public void isLive(). 

Running the code now I want to see that the updated text is displayed.  This is the output from the original method, and, now ... the update text.  Yes, this course, 'Java 8 for Complete Beginners is live'.

In this lecture you learnt the solution to the anonymous class coding exercise. 
 
I am Marius from AlefTav Coding.  In the next lecture we will cover the second last topic in this course.  Till then, KEEP CODING.

Anonymous classes Solution
05:33

// Lecture 50: Inheritance Example

// EXAMPLE PROBLEM STATEMENT: 
// Implement ‘inheritance’ with the child class named 'JavaCourse'.

// EXAMPLE SOLUTION: 
// public class JavaCourse extends Course // Inheritance

// Learning in general
// Studying Java

Hi, there, this is Marius from AlefTav Coding.  In this lecture you will learn how to implement inheritance in Java.

Inheritance refers to a parent-child relationship, where one class acts as the parent and another class as a child.  

Lets first see how this works, before looking at the code in IntelliJ.  Here we have a parent class, 'Course', with a method, 'learn' that prints the text, 'Learning in general'.  Next, we have a child class, 'JavaCourse', which contains the same members as the parent class.  How you do this in Java, is to add the keyword, 'extends' after the name of the child class, followed by the name of the parent class.  I want to use the same method, 'learn' from the parent class, here in the child class.  You do this by typing the '@Override' annotation before the name of the method. Now, I can add code that is specific to the child class, here the text, 'Studying Java'.

In my main program I create an object of the parent class, and call the method, 'learn' in the parent class.  I create another object, this time of the child class, and call the method, 'learn' in the child class.  When you run the program this is the code from the two methods.

In IntelliJ the problem statement reads, 'Implement 'inheritance' by overriding the method named ‘learn’ in the parent class.  Create an object and call this method in the child class.

This is the output when the parent object calls the method, and this is printed when the child object calls the overridden method.  The solution is to create a child class, 'JavaCourse' with the 'extends' keyword.  

Looking now at our program.  In the main file we hava a class, 'Lecture50' with a main method.  We create a parent object, that calls the method 'learn' in the parent class.  Then we create a child object, which calls the overridden method, 'learn' in the child class.

In the second file, here, we have the parent class with the method 'learn' that prints this text.  Then, in the third file, we have an overridden method this text.  It is here that we need to type the solution, which is the heading of the child class.  I will remove the line comment and type public class JavaCourse extends Course // inheritance

Back in my main file, yes, my code is ready to be run.  So, when I run the program I want to see these 2 lines displayed.  This first output is the printout of the code where the parent object does the call.  And this second output is the printout of the code where this child object does the call. 

In this lecture you learned to use 'inheritance' in Java.

Now, to re-inforce what you learned, please go ahead and do this coding exercise. 

// INHERITANCE CODING EXERCISE:
// Implement inheritance with the child class named 'Programming'
 
I am Marius from AlefTav Coding.  See you in the next video and, as always, KEEP CODING.

Inheritance Example
06:58

Lecture 51
1 question

// Lecture 51: Inheritance Solution

// INHERITANCE CODING EXERCISE:
// Implement inheritance with the child class named 'Programming'

// INHERITANCE SOLUTION:
// public class Programming extends Software

// General software solutions Programming solutions

Hi there, This is Marius from AlefTav Coding.  In this lecture you will learn the solution to the inheritance coding exercise. 

The problem statement asked you to 'Implement inheritance with the child class named 'Programming'.  

The output here is the text from the method, 'solveProblems' in the parent class, 'General software solutions'.  Then, a space and the text from the overridden method, 'solveProblems' from the child class.  This text is 'Programming solutions'

Here in our expected solution we see the header of a Java class that is a child class.  'public class, then the name of the child class 'Programming' followed by the keyword 'extends' and the name of the parent class, here 'Software'.

I have here a main file with class, 'Lecture51' and a main method.  In main I have created a parent object that calls the method, 'solveProblems' in the parent class.  Next, I created a child object that calls the overridden method, 'solveProblems' in the child class.  

Now to the second file where we have the parent class, 'Software'.  In here is the method, 'solveProblems' that prints this text.  There is a space after this string.  On to the third file where I have a method, 'solveProblems' that overrides the one in the parent class.  It is here that I need to type the solution by implementing inheritance.  I will remove the line comment and type 'public class Programming extends Software' 

Back in the main program I am now ready to test this code.  Let me click run, and I want to compare and see if the actual printout agrees with this expected line.  Happy day, because IntelliJ confirms that my actual code is the same as the expected code.

In this lecture you learnt the solution to the inheritance coding exercise. 
 
I am Marius from AlefTav Coding.   The next 2 lectures are on the concept of 'polymorphism'.  Until then, KEEP CODING.

Inheritance Solution
05:25

// Lecture 52: Polymorphism Example

// EXAMPLE PROBLEM STATEMENT: 
// Implement ‘polymorphism’ by creating a child object
// with a parent class as dataType

// EXAMPLE SOLUTION:
// Programming programming2 = new Java();

// Programming is writing software
// Java is object-oriented

Hi, there, this is Marius from AlefTav Coding.  In this lecture you will learn how to implement 'polymorphism' in Java.

Polymorphism refers to the situation where a child class describes its own unique behavior.

Lets turn to the slides before studying the code in IntelliJ.  Here you have a parent class, 'Programming' with a method, 'printDescription' that outputs the text, 'Programming is writing software'.  Next is a child class, 'Java' with an overridden method, 'printDescription' that prints text describing Java, that 'Java is object-oriented'. 
In your main method you create an object of the parent class, 'programming1'.  It calls the method, 'printDescription' in the parent class.  Then you create another object.  This object, 'programming2' also has as its dataType the parent class, 'Programming'.  But it is a reference to the child class, 'Java'.  This child object also calls the method, 'printDescription'.  What do you think will be the output from this call?  Let's see, the first call prints the text from the parent class, but the second call prints the text from the child class.
This is 'polymorphism' in action.

In IntelliJ, this lecture's problem statement is, 'Implement ‘polymorphism’ by creating a child object with a parent class as dataType'

The output is this code from the parent class, and this from the child class.  The solution is, parent class, 'Programming' with a storageName 'programming2' that is a reference to the child class, '= new Java();'

Looking at this file, we have a class, 'Lecture52' with a main method.  In main we create a parent object. And then call the method, 'printDescription' in the parent class.  Then, leaving this line for the moment, we have an object, that calls the same method, 'printDescription'

In our second file here is the parent class, 'Programming' with the method 'printDescription' which outputs this text.  In our third file, here is the child class, 'Java', with an overridden method, 'printDescription'. that prints this text.  

In my main program I will now implement polymorphism.  Let me create an object by typing as dataType the parent class, 'Programming' and storageName 'programming2'.  I will initialize it as 'new Java', which is a reference to the child class.  

My code has received the all clear so let's run it. And I expect to see the text from the parent class, followed by the text from the child class.  And there we have it.

In this lecture you learned to use polymorphism in Java.

Now, to practice this concept, here is the coding exercise. 

// POLYMORPHISM CODING EXERCISE:
// Implement ‘polymorphism’ by creating a child object, 'coding2' 
// with a parent class, 'Coding' as dataType 

I am Marius from AlefTav Coding.  See you in the next video and, till then, KEEP CODING.

Polymorphism Example
06:57

Lecture 53
1 question

// Lecture 53: Polymorphism Solution

// POLYMORPHISM CODING EXERCISE:
// Implement ‘polymorphism’ by creating a child object, 'coding2' 
// with a parent class, 'Coding' as dataType

// POLYMORPHISM SOLUTION:
// Coding coding2 = new Java8();
 
// Java 8 codes functional style

Hi there, This is Marius from AlefTav Coding.  In this lecture you will learn the solution to the polymorphism coding exercise. 

The problem statement asked you to 'Implement ‘polymorphism’ by creating a child object, 'coding2' with a parent class, 'Coding' as dataType

The expected output here is the text from the overridden method, 'Java 8 codes functional style'.

And here is the solution, declaration 'Coding coding2' then initialzed as the child class, '= new Java8();'

Your main file has a class, 'Lecture53' with a main method.  In main you have an object, 'coding2' that calls a method, 'printDescription'.  In the second file is the parent class, 'Coding' with a method, printDescription, that does not have any code.

Then, our third file has the child class, 'Java8' with an overridden method, 'printDescription'.  This method has a print statement that says, 'Java8 codes functional style'.  As the overridden method, this is the code I want to see printed out.

Back in my main file, I will remove the line comment and type the solution implementing polymorphism.  parent class dataType, 'Coding' with storageName 'coding2' as a reference to the child class '= Java8();'

IntelliJ says we are good to go.  So, when I can run the code I want to see this text, that 'Java 8 codes functional style'.  And there, our expected outcome.

In this lecture you have learnt the solution to the polymorphism class coding exercise. 
 
I am Marius from AlefTav Coding.   The next lecture will be the last of this course.  Until then, KEEP CODING.

Polymorphism Solution
03:58
+
Conclusion
1 Lecture 02:40

// Lecture 54: Final Remarks

Hi, there, this is Marius from AlefTav Coding with the last lecture of this course, 'Java 8 for Complete Beginners'.  In this video I will talk briefly about your java journey. 

If this is your first time doing coding, you will find java programming tough-going.  Remember, though, that many millions of programmers have been where you are now.  At first, just about everyone finds programming difficult.  And, realistically, it takes some months of working consistently before programming starts making sense.  

Your journey on the road to Java mastery has only just started, but, you have now laid a firm foundation on which to start refining your java skills.  

In order to achieve full mastery in Java you need to study the code of experienced java developers, as well as writing lots and lots of code.  Also bear in mind that Java programming success only comes to those who keep going.  Furthermore, in programming, you never stop learning.
    
Your next step would be to take a course such as my Java 8 for intermediate users.

Before that, here are 3 small projects for you to complete.  You can also find the problem statement of these projects on the PDF of this lecture.  I did not provide solutions for these projects.  However, if there is interest from you, I will make solutions available.  
 
I am Marius from AlefTav Coding.  I look forward to working again with you in the next course, and, as always KEEP CODING.

Final remarks
02:40
About the Instructor
Marius Claassen
4.3 Average rating
26 Reviews
1,360 Students
2 Courses
Java Developer and Teacher

I taught myself to program using Java.  Having been a teacher for many years, I am now working full-time as an independent software instructor, making video tutorials.  My passions are learning, teaching and Java in equal measure.  It is my mission to help others learn programming in general and Java in particular.