
Explore the grammar of Java to write clean, readable, and professional code by mastering packages, classes, comments, and naming conventions.
Explore Java's strongly typed system and the eight primitive types, learn how variables, scope, and casting move data between containers, and master common operators and short-circuiting.
Learn to read a radius from the keyboard in Java with a scanner, use descriptive variable names, compute the circle area (pi times r squared), and display the result.
Learn the basic building blocks of Java, including objects, strings, methods, and variables, and explore immutable versus mutable strings, with a simple initials example and user input.
In Java, wrapper classes are the object counterparts of the eight primitive types—Boolean, Byte, Short, Integer, Long, Float, Double, and Character. They encapsulate a primitive value inside an immutable object, enabling features that require objects rather than primitives, such as use with generics and collections (List<Integer> instead of List<int>), method returns that may be null, and utility functionality (parsing and formatting via Integer.parseInt, Double.valueOf, constants like MAX_VALUE). Since Java 5, autoboxing and unboxing automatically convert between primitives and wrappers (e.g., int ↔ Integer), making code cleaner but with potential overhead and NullPointerException risks when unboxing null. In performance-critical paths, prefer primitives; use wrappers when object semantics, nullability, or API requirements make them necessary.
Explore loops, including while and for loops, and manage definite and indefinite repetitions with initialization, condition, and update. Apply counter and accumulator patterns to automate repetitive tasks in coding.
Demystify arrays in Java by declaring, creating, and accessing one-dimensional arrays, mastering zero-based indexing and length, then extend to arrays of arrays to build matrices and perform sums.
Learn how one-dimensional arrays work in Java, including declaring an array, creating with new, zero-based indexing, accessing elements, using the length property, default initialization, and initializing via a for loop.
Learn core array operations in Java, including initialization with random numbers, printing, summing, averaging, max and min, for-each traversal, shuffling, shifting, and safe copying with loops or System.arraycopy.
In Java, arrays are special container objects that hold a fixed number of elements of a single type, allowing efficient storage and random access to data. The array itself is an object derived from the Object class, which means it has properties like length and can be passed to methods or returned from them. Arrays can be one-dimensional (e.g., int[] nums = new int[5];), multidimensional (e.g., int[][] matrix = new int[3][3];), or even jagged (arrays of arrays with varying lengths). Once created, the size of an array cannot change, which makes it suitable for scenarios where the number of elements is known in advance.
Although arrays are built into Java’s syntax, the java.util.Arrays class provides many useful utility methods for manipulating them. This includes methods such as Arrays.sort() for sorting, Arrays.binarySearch() for searching, and Arrays.equals() or Arrays.deepEquals() for comparing arrays. You can also use Arrays.copyOf() and Arrays.fill() to duplicate or initialize array values easily. For displaying contents, Arrays.toString() and Arrays.deepToString() convert arrays to human-readable string forms, which is particularly helpful for debugging.
Java arrays can store either primitive types (like int, char, double) or object references (like String, Integer). When used with objects, only references are stored, not the actual objects themselves. Since arrays are fixed-size, when flexibility is needed—such as dynamic resizing or type-safe operations—collections like ArrayList are typically preferred. However, arrays remain fundamental in Java because of their simplicity, performance efficiency, and direct memory representation, which make them essential for low-level data structures, numerical computations, and performance-critical applications.
Implement a static method count coins that reads an input file via a scanner, tallies pennies, nickels, dimes, and quarters case-insensitively, and prints the total money.
This lecture explains a static method matchIndex that uses a scanner to compare neighboring line pairs for matching chars at zero-based indices, printing indexes or none.
Demonstrate static methods in Java by implementing an isPrime boolean to test numbers up to 10,000, print primes, and optimize by looping only to the square root for efficiency.
Explore a Java-based computer-assisted instruction example that helps elementary students practice multiplication using a secure random generator, prompts, and a looping check until the answer is correct.
Implement randomized feedback in a computer-assisted instruction program using a random number generator and a switch case to display varied messages for correct and incorrect answers.
Explore a computer-assisted instruction example that adjusts math questions by difficulty, generates random numbers within ranges, tracks answers and correctness, and computes the percentage score after every ten questions.
Enable a Java program to let users choose arithmetic types (addition, subtraction, multiplication, division, or random) with static final constants, input validation, and restart after ten questions.
Explore object oriented programming in Java by defining objects with state and behavior, using classes as blueprints and constructors to instantiate circle objects with data fields and get area.
Examine how instance methods require an object to call and access instance variables, while static methods and static variables are shared across all instances, including getters and setters.
Explore how a time class uses private hour, minute, and second fields with overloaded constructors and validation to throw illegal argument exceptions, and formats time in universal and standard representations.
Play a high-low card game that deals a card from a deck, asks you to predict higher or lower for the next card, and tracks your score with an average.
Standard Poker Hand Ranking
There are 52 cards in the pack, and the ranking of the individual cards, from high to low, is ace, king, queen, jack, 10, 9, 8, 7, 6, 5, 4, 3, 2. There is no ranking between the suits – so for example the king of hearts and the king of spades are equal.
A poker hand consists of five cards. The categories of hand, from highest to lowest, are listed below. Any hand in a higher category beats any hand in a lower category (so for example any three of a kind beats any two pairs). Between hands in the same category the rank of the individual cards decides which is better, as described in more detail below.
S=Spades C= Clubs H= Hearts D=Diamonds
1. Royal Flush
This is the highest poker hand. It consists of ace, king, queen, jack, ten, all in the same suit. If there are 2 royal flushes in the running for High hand, then the ranking order from highest to lowest is Spades, Hearts, Diamonds and Clubs.
2. Straight Flush
Five cards of the same suit in sequence – such as CJ-C10-C9-C8-C7. Between two straight flushes, the one containing the higher top card is higher. An ace can be counted as low, so H5-H4-H3-H2-HA is a straight flush, but its top card is the five, not the ace, so it is the lowest type of straight flush. The cards cannot “turn the corner”:D4-D3-D2-DA-DK is not valid.
3. Four of a kind
Four cards of the same rank – such as four queens. The fifth card can be anything. This combination is sometimes known as “quads”, and in some parts of Europe it is called a “poker”, though this term for it is unknown in English. Between two fours of a kind, the one with the higher set of four cards is higher – so 3-3-3-3-A is beaten by 4-4-4-4-2. In Texas Hold’em, if the board shows “quads”, then the player with the higher fifth card is the winner.
4. Full House
This consists of three cards of one rank and two cards of another rank – for example three sevens and two tens (colloquially known as “sevens full” or more specifically “sevens on tens”). When comparing full houses, the rank of the three cards determines which is higher. For example 9-9-9-4-4 beats 8-8-8-A-A. If the threes of a kind were equal, the rank of the pairs would decide.
5. Flush
Five cards of the same suit. When comparing two flushes, the highest card determines which is higher. If the highest cards are equal then the second highest card is compared; if those are equal too, then the third highest card, and so on. For example SK-SJ-S9-S3-S2 beats DK-DJ-D7-D6-D5 because the nine beats the seven.
6. Straight
Five cards of mixed suits in sequence – for example SQ-DJ-H10-S9-C8. When comparing two sequences, the one with the higher ranking top card is better. Ace can count high or low in a straight, but not both at once, so A-K-Q-J-10 and 5-4-3-2-A are valid straights, but 2-A-K-Q-J is not. 5-4-3-2-A is the lowest kind of straight, the top card being the five.
7. Three of a Kind
Three cards of the same rank plus two other cards. This combination is also known as Triplets or Trips. When comparing two threes of a kind the hand in which the three equal cards are of higher rank is better. So for example 5-5-5-3-2 beats 4-4-4-K-Q. If you have to compare two threes of a kind where the sets of three are of equal rank, then the higher of the two remaining cards in each hand are compared, and if those are equal, the lower odd card is compared.
8. Two Pair
A pair is two cards of equal rank. In a hand with two pairs, the two pairs are of different ranks (otherwise you would have four of a kind), and there is an odd card to make the hand up to five cards. When comparing hands with two pairs, the hand with the highest pair wins, irrespective of the rank of the other cards – so J-J-2-2-4 beats 10-10-9-9-8 because the jacks beat the tens. If the higher pairs are equal, the lower pairs are compared, so that for example 8-8-6-6-3 beats 8-8-5-5-K. Finally, if both pairs are the same, the odd cards are compared, so Q-Q-5-5-8 beats Q-Q-5-5-4.
9. Pair
A hand with two cards of equal rank and three other cards which do not match these or each other. When comparing two such hands, the hand with the higher pair is better – so for example 6-6-4-3-2 beats 5-5-A-K-Q. If the pairs are equal, compare the highest ranking odd cards from each hand; if these are equal compare the second highest odd card, and if these are equal too compare the lowest odd cards. So J-J-A-9-3 beats J-J-A-8-7 because the 9 beats the 8.
10. High Card
Five cards which do not form any of the combinations listed above. When comparing two such hands, the one with the better highest card wins. If the highest cards are equal the second cards are compared; if they are equal too the third cards are compared, and so on. So A-J-9-5-3 beats A-10-9-6-4 because the jack beats the ten.
Explore a four in a row game built with object-oriented programming, featuring a game control class, column objects, and mouse interactions to manage turns and wins.
Explore the Java collections framework, learn to use collection classes and iterators, and choose appropriate collections for problems, including stacks, queues, linked lists, sets, maps, and priority queues.
Explore the java collections sets: hash set uses hash tables to speed up contains, add, and remove, while tree set uses balanced binary trees; both store unique, unordered elements.
Explore how maps in the Java collections framework store keys and values and their associations. Store books with unique barcodes and retrieve them efficiently by key.
Compare array and ArrayList in Java by reading file words with a scanner, storing them, and printing reverse. See how ArrayList resizes dynamically and offers add, get, remove, and size.
Demonstrate reversing an array list of binary numbers by pushing strings onto a stack and popping them into a second list, producing 15 down to 0 in binary.
Explore a generic Java method that reverses any object array using a T type, swapping elements with low and high indices and a temporary variable.
Explore declaring a generic class with type variables, illustrated by a box that stores different data types. Learn to declare single and multi-type generics and avoid explicit type casting.
Build a stack data structure, starting with an integer version and then generalizing it to a generic class for different data types, demonstrating push, pop, and reversing an array.
Explore a generic Java bag implementation using a fixed-size array, with add, remove, isEmpty, getCurrentSize, contains, and getFrequencyOf operations.
Implement a generic array bag that implements the bag interface, with a default capacity, a backing array, and a number of entries, plus add and toArray methods.
Enhance bag security by validating input, enforcing a 10,000 capacity, and guarding integrity with exceptions while demonstrating add and test utilities for array bag implementations.
Implement a bag backed by an array, with is empty, get current size, and get frequency. Include contains, clear, remove by index or item, and dynamic resizing by doubling capacity.
Explore resizing an array-backed bag in Java with Arrays.copyOf, doubling capacity, and capacity checks, including maximum capacity handling and the trade-offs of copying versus using a linked list.
Explore the resizable array bag implementation that follows a generic bag interface with add, remove, contains, get frequency, to array, and dynamic capacity doubling in Java.
*New* Enroll in one course and receive a 100% free coupon to one of my other courses! Please contact me after registering in one of the courses and let me know which other course you prefer.
Update November 2025: Several AI-powered lecture videos have been uploaded to explain the fundamentals of programming for beginners
This course is a comprehensive, example-driven introduction to Java programming and Object-Oriented Programming (OOP), designed to take you from absolute basics to advanced object-oriented design concepts with confidence.
You begin by understanding how programs work, how Java code is structured, and how to write clean, readable programs. Fundamental topics such as variables, operators, strings, wrapper classes, and input handling are introduced gently, with practice sessions that help you build intuition early on.
As you progress, you will master control structures, arrays, and methods through many step-by-step examples and exam-style problems. These sections focus on building strong problem-solving skills and writing modular, reusable code. Recursion, file processing, and array manipulation are explained clearly with practical use cases.
The core of the course focuses on object-oriented programming in Java. You will learn how to design classes, use access modifiers correctly, implement getters and setters, and model real-world problems using objects. Multiple case studies—such as matrix classes, time classes, and card games—demonstrate how OOP concepts are applied in real programs.
Advanced OOP topics are covered in depth, including class relationships, inheritance, polymorphism, abstract classes, interfaces, generics, and the Java Collections Framework. You will work with lists, sets, maps, stacks, and custom abstract data types, gaining a solid understanding of both theory and implementation.
The course also introduces GUI and 2D graphics programming, helping you visualize logic and create interactive programs.
By the end of this course, you will be able to:
Write clean, structured Java programs
Design and implement object-oriented solutions
Use collections, generics, and interfaces effectively
Understand and apply inheritance and polymorphism
Tackle exam problems and real-world programming tasks confidently
This course is ideal for beginners, university students, and anyone who wants a strong, practical foundation in Java and object-oriented programming.