Java Tutorial for Beginners | Learn Java in 2 Hours
Introduction to Java Course
Overview of the Course
- This video introduces a new Java course that spans two hours, focusing on basic installation and comprehensive coverage of the Java programming language. Notes are provided for reference throughout the course.
- The course aims to equip learners with coding skills, culminating in a mini project at the end. Prior knowledge from over 200 videos on web development (HTML, CSS, JavaScript) is suggested as beneficial.
Setting Up Your Environment
Downloading JDK
- To begin coding in Java, users must first download the Java Development Kit (JDK). Instructions include searching for "jdk download" and selecting the appropriate version based on their operating system (Linux, Windows, or Mac).
- After downloading JDK, users need to install it by opening the downloaded file and following prompts for installation including entering user credentials.
Choosing an Editor
- The next step involves downloading an editor; IntelliJ is recommended as a suitable option. Users should search for "IntelliJ download" and select the community version which is free. Installation instructions include dragging it into the applications folder after downloading.
- Once installed, users will open IntelliJ and proceed through initial setup steps before creating a new project within the IDE.
Creating Your First Project
Project Setup in IntelliJ
- In IntelliJ, users will create a new project by selecting options such as Maven or Gradle but should stay focused on Java for this course. The correct SDK version (16) will be automatically selected if JDK was installed correctly.
- Users can opt to use sample code provided by checking a specific box during setup which simplifies starting out with pre-written code snippets. They will then name their project and package appropriately based on organizational standards similar to library sections for books.
Understanding Code Structure
Package Naming Conventions
- Packages serve as containers for related files; naming conventions follow reverse domain style (e.g., com.google.college). This structure helps organize code effectively within projects similar to how books are categorized in libraries.
Main Class and Functions
Introduction to Java Programming
Understanding Comments in Code
- The gray highlighted area indicates a section for comments, where users can write notes in various languages without affecting the code execution.
- In Java, comments are created using double slashes (//) for single-line comments and /* */ for multi-line comments.
Writing Your First Program
- The first program typically outputs "Hello World," which is fundamental in programming.
- To display output in Java, the command
System.out.printlnis used, which is more verbose compared to other languages like C++ or Python.
Semicolons and Code Execution
- A semicolon (;) signifies the end of a statement in Java, similar to how a period ends a sentence in English.
- Running the code prints "Hello World" or any string passed to
println, demonstrating successful execution.
Output Variations with Print Methods
- Using
printlnadds a new line after printing, while usingprintdoes not. This distinction affects how output appears on the console.
- IntelliJ IDEA offers shortcuts like typing "SOUT" followed by tab to quickly generate
System.out.println.
Variables and Data Types
Introduction to Variables
- Variables store data temporarily in memory; for example, declaring a string variable as
String name = "man"assigns the value "man" to the variable name.
Storing Multiple Values
- Additional variables can be declared similarly; e.g., an integer variable can be defined as
int age = 30, storing numeric values.
Variable Types and Memory Management
- Different types of data can be stored using variables: strings for text and integers for numbers. Each variable points to a specific location in memory.
Primitive vs Non-Primitives Data Types
- Primitive types hold simple values (e.g., byte), while non-primitives or reference types store complex values. Understanding these distinctions is crucial for effective programming.
Data Types and Memory Storage in Programming
Understanding Data Types
- The discussion begins with the concept of data types, specifically focusing on memory allocation for different types. For instance, a short integer uses 2 bytes of memory.
- Boolean values are introduced as a type that can store two possible values: true or false. This is likened to binary states like yes/no or on/off.
Capacity and Error Handling
- The speaker explains the importance of understanding data type ranges. Attempting to store numbers outside these ranges results in errors, emphasizing the need for careful selection of data types.
- An example illustrates storing an integer value (like a phone number). If the number exceeds the range of an integer type, it leads to an error indicated by a red line in code.
Working with Long and Float Types
- To handle larger numbers, one should use long data types. A capital 'L' indicates that a number is being stored as a long type rather than an integer.
- When dealing with float values, it's crucial to denote them correctly (e.g., using capital 'F') to avoid conversion errors when assigning decimal numbers.
Boolean Logic in Programming
- The speaker discusses how boolean variables can change based on conditions. For example, if age changes from 30 to 12, it affects the boolean output accordingly.
Non-Primitive Data Types: Strings
- Transitioning into non-primitive types, strings are defined as collections of characters forming words or lines. They allow for more complex data storage compared to primitive types.
- A variable named "name" is created with string type and assigned a value ("amant"), showcasing how strings can hold multiple characters without fixed size limitations.
Functions Associated with Non-Primitive Types
- The length function is introduced as a method applicable to strings that returns the number of characters stored within them.
Differences Between Primitive and Non-Primitives
- Key differences between primitive and non-primitives are highlighted; non-primitives have methods associated with them allowing various operations such as retrieving lengths or manipulating content.
Creating New String Instances
- When creating new string instances using keywords like "new," it allows for dynamic memory allocation without encountering errors related to fixed sizes typical in primitive types.
Understanding String Operations in Java
Introduction to Strings
- Strings are reference types in Java, meaning they do not require the
newkeyword for assignment. This allows for straightforward string manipulation and usage.
Concatenation of Strings
- To concatenate two strings, you can use the
+operator. For example, combiningname1andname2results in a new stringname3. Printing this will show the concatenated output.
Inserting Spaces Between Strings
- When concatenating strings, you can insert spaces by including them explicitly between the strings. This ensures that when printed, the output appears correctly formatted with spaces.
Accessing Characters in a String
- The method
.charAt(index)is used to access characters at specific positions within a string. Remember that indexing starts from 0 in Java; thus, position 1 corresponds to index 0. For instance, accessing index 0 returns 'A' if the string is "Am".
Length of a String
- The length of a string can be obtained using
.length(), which returns the total number of characters present in the string. For example, callingname.length()on "Amann" would return 5.
String Replacement and Immutability
Replacing Characters in Strings
- The
.replace(oldChar, newChar)method allows replacing specified characters within a string without altering the original string itself; it creates and returns a new modified version instead. For instance, replacing 'A' with 'B' results in "MBnn".
Understanding Immutability of Strings
- In Java, strings are immutable; once created, their content cannot be changed directly. Any modification results in creating a new string rather than altering the existing one. This characteristic is crucial for memory management and performance optimization within applications.
Substring Method Usage
Extracting Substrings
- The substring method
.substring(startIndex, endIndex)extracts parts of a string based on specified indices where startIndex is inclusive while endIndex is exclusive (not included). For example: extracting from index 0 to 4 gives "Amann". To get three characters starting from index 6 requires specifying an end index of 9 (exclusive).
Introduction to Arrays
Storing Multiple Values Using Arrays
Understanding Arrays in Java
Introduction to Arrays
- In Java, arrays are used to store multiple values of the same type. They can hold various data types including integers, strings, and even other arrays.
- To declare an array in Java, you specify the data type followed by two square brackets. This indicates that a list (array) is being created.
Declaring and Initializing Arrays
- An example of declaring an integer array named
marksinvolves using thenewkeyword to allocate memory for three integer values.
- The first three positions of the
marksarray are assigned values: 97 for physics, 98 for chemistry, and 95 for English.
Accessing Array Values
- When attempting to print the entire array directly in Java, it does not display stored values but rather a class name and hash code.
- To access specific elements within the array, use their index with square brackets (e.g.,
marksfor physics marks).
Initialization Behavior in Java
- Unlike C++, uninitialized variables in Java default to null or zero. For instance, if no value is assigned to an integer array like
marks, it will show zeros when printed.
- If a boolean type array is declared without initialization, it defaults to false; similarly, uninitialized primitive types also yield default values.
Important Array Functions
- Two key functions related to arrays include
.length, which returns the number of elements in an array without parentheses since it's a property rather than a method.
- The second important function is sorting. The built-in
Arrays.sort()method allows sorting of arrays in ascending order.
Using Array Class Methods
- To sort an array using the
Arrays.sort()method from the java.util package requires importing this package at the beginning of your code.
Understanding Arrays and Casting in Java
Introduction to Array Initialization
- The class will focus on importing packages and initializing arrays. The speaker emphasizes the importance of understanding how to print array elements, starting with
Macs.
Working with One-Dimensional Arrays
- The speaker discusses commenting out code to observe differences in output when printing array values. They highlight that the array functions as a collection of elements.
- When defining strings or arrays, if the elements are known, there's no need for the
newkeyword; instead, values can be assigned directly.
Creating Two-Dimensional Arrays
- To store multiple students' marks across subjects like physics, chemistry, and English, two-dimensional arrays (2D arrays) are introduced.
- A 2D array is created using two pairs of square brackets. For example,
finalMarksholds marks for two students across three subjects.
Accessing Elements in 2D Arrays
- The process of accessing specific student marks is explained by indexing into the 2D array. For instance, retrieving the first student's mark involves referencing index positions correctly.
- The speaker demonstrates how to print individual subject marks for each student by navigating through indices.
Understanding Casting in Java
- An important concept introduced is casting—converting one data type into another. This can be implicit or explicit.
- An analogy involving water containers illustrates casting: a small glass versus a large bucket represents different data types and their capacities.
Practical Examples of Casting
- When calculating prices with GST using double data types shows how casting works practically within programming contexts.
- Issues arise when trying to cast larger data types (like double) into smaller ones (like int), leading to potential information loss.
Implicit vs Explicit Casting
- The distinction between implicit and explicit casting is clarified: Java allows storing an integer value in a double variable but not vice versa without explicit conversion.
Understanding Implicit and Explicit Casting in Programming
Implicit and Explicit Casting
- The discussion begins with the concept of implicit casting, where a double variable is stored in an integer type without explicit instructions. This is allowed when the value fits within the capacity of the target type.
- Explicit casting is introduced as a method to convert data types when there may be data loss. It requires using parentheses to specify the target type, such as converting a double to an integer.
- When printing values after casting, decimals are truncated. For example, if 18.99 is cast to an integer, it will print as 18 instead of retaining decimal values.
- The speaker emphasizes that while compatible types can be converted (e.g., integers), incompatible types (like strings to integers) cannot be cast directly.
Constants vs Variables
- A variable like age can change over time; for instance, next year’s age will increment by one. This illustrates how variables hold mutable values.
- Constants are defined using the
finalkeyword in programming languages. An example given is pi (3.14), which should remain unchanged throughout code execution.
- If a constant's value is attempted to be changed after its declaration with
final, an error occurs indicating that assignment to a final variable isn't permitted.
Exploring Operators in Programming
Types of Operators
- The discussion transitions into operators used in programming: arithmetic operators, assignment operators, logical operators, and comparison operators are highlighted.
Arithmetic Operators
- Arithmetic operators include addition (+), subtraction (-), multiplication (*), division (/), and modulus (%). These are fundamental for performing mathematical operations within code.
- An example demonstrates basic arithmetic: adding two numbers (a = 1 and b = 2). The output correctly shows their sum as 3.
Division and Truncation
- When dividing integers (e.g., 1 divided by 2), results may truncate decimal points due to integer type limitations; thus, it outputs zero instead of 0.5 unless explicitly defined as double or float.
Modulus Operator
- The modulus operator (%) finds the remainder from division operations. For instance, dividing 1 by 2 yields a remainder of 1 when printed out.
Understanding Division and Remainders in Arithmetic
Division Basics
- When dividing 1 by 2, a remainder of 1 is produced. This concept extends to other divisions, such as dividing 5 by 3, which results in a remainder of 2.
- The module operator can be used to eliminate the remainder when performing division operations.
Assignment Operators
- Assignment operators are frequently utilized for assigning values to variables. They play a crucial role in defining how numbers are manipulated within programming.
- Unary operators work alongside assignment operators; they require only one operand (e.g., A or B) for operations like addition or multiplication.
Incrementing Values with Unary Operators
- An example illustrates initializing a variable with the value of 1 and incrementing it using the unary operator
++, resulting in an output of 2.
- The difference between pre-increment (
++number) and post-increment (number++) is highlighted: pre-increment changes the value before printing, while post-increment prints the original value first.
Exploring Decrement Operators
Understanding Decrement Operations
- The decrement operator (
--) functions similarly to the increment operator but decreases the variable's value instead.
- Using post-decrement shows that the original value is printed first before being decremented, demonstrating how unary operators affect variable states.
Java Math Class Functions
Utilizing Max and Min Functions
- The Java Math class provides useful functions like
Math.max(), which returns the maximum of two numbers (e.g.,Math.max(5, 6)outputs 6).
- Similarly,
Math.min()can be used to find the minimum value between two numbers (e.g.,Math.min(5, 6)outputs 5).
Generating Random Numbers
- The
Math.random()function generates random values between 0.0 and 1.0. This function can be called directly for generating random numbers.
- To convert this random number into an integer form, explicit casting is necessary after multiplying by a desired range (e.g., multiplying by 100).
Understanding Input Handling in Java
Creating a Scanner for Input
- The process begins with creating a random function to print random values, followed by discussing how to get input using the standard class name.
- A
Scannerobject is created usingjava.util.Scanner, which allows for input handling. The red lines indicating errors disappear once the scanner class is properly imported.
Taking User Input
- The program prompts the user for their age and stores it in an integer variable using
SC.nextInt().
- After entering an age (e.g., 30), the program successfully prints back the entered value, demonstrating basic input functionality.
Handling Different Data Types
- For float values, users can enter decimal numbers (e.g., 40.0), showcasing that various data types can be handled through the scanner.
- To capture string inputs, a string variable is created and filled using
SC.next(), but only single tokens (words) are captured.
Capturing Full Sentences
- When attempting to input full sentences, only the first word is printed due to token limitations of
next().
- To capture entire lines of text,
nextLine()should be used instead ofnext(), allowing for complete sentence inputs.
Comparison Operators and Conditional Statements
Understanding Comparison Operators
- Before diving into conditional statements, comparison operators are introduced as tools for evaluating numerical relationships.
- The equality operator (
==) checks if two values are equal; if true, it returns true; otherwise false.
Not Equal and Other Comparisons
- The not equal operator (
!=) uses an exclamation mark to denote inequality between two variables.
- Greater than (
>) and less than (<) operators help determine numerical relationships along with their inclusive counterparts (greater than or equal to, less than or equal to).
Introduction to Conditional Statements
- Conditional statements like "if" and "else" allow branching logic based on boolean conditions. An example illustrates checking if "the sun is up" determines whether it's day or night.
Implementing Conditionals in Code
Understanding Conditional Statements and Logical Operators in Java
Introduction to Conditional Statements
- The discussion begins with the concept of conditional statements in Java, specifically focusing on determining if it is night based on the absence of sunlight.
- An example is provided where an age (30) is checked against a voting eligibility condition (greater than 18), demonstrating how to print whether someone can vote or not.
Logical Operators Explained
- The session transitions into logical operators, starting with the AND operator. It states that both conditions must be true for the final output to be true.
- An example illustrates this: if A (30) and B (40) are both less than 50, it prints "both less than 50." If either condition fails, no output is produced.
Using OR Operator
- The discussion shifts to the OR operator, which requires at least one condition to be true for a positive outcome.
- A practical example shows that if either A or B is less than 50, it will print "at least one less than 50."
Negation with NOT Operator
- The NOT operator is introduced as a way to negate conditions. If a condition evaluates as true, using NOT will make it false and vice versa.
- An example demonstrates this by checking a Boolean variable 'adult'. If it's true, it prints "It is adult"; otherwise, it prints "Not adult."
Code Optimization Techniques
- The speaker discusses code optimization by eliminating unnecessary checks for truth values within conditional statements.
- It emphasizes that even without explicitly stating 'true', Java will automatically evaluate conditions correctly.
Practical Application: User Input Example
- A scenario involving user input for purchasing items (pen priced at 10 rupees and notebook at 40 rupees) illustrates how conditional statements guide decisions based on available cash.
- The program prompts users about their spending capacity and uses conditional logic to determine what they can buy based on their input.
Understanding Conditional Statements and Loops in Java
Conditional Statements: If-Else and Switch
- The discussion begins with an explanation of conditional statements, specifically focusing on the
if-elsestructure. It checks if cash is greater than 10 and less than 40 to determine what can be purchased.
- If cash exceeds 50 rupees, the program indicates that both items (pen and pencil) can be bought. This illustrates how conditions dictate program flow based on user input.
- A practical example is provided where a user inputs their cash amount. For instance, entering 7 rupees results in no purchases possible, while 60 rupees allows for two items.
- The transition to the
switchstatement is introduced as another type of conditional statement that evaluates a single variable against multiple cases.
- An example using days of the week demonstrates how
switchworks, with specific cases for each day (1 for Monday, 2 for Tuesday), culminating in a default case for other values.
Execution Flow in Switch Statements
- When executing a switch statement, once a case matches, all subsequent statements are executed unless interrupted by a
break.
- The importance of the
breakkeyword is highlighted; it prevents fall-through behavior by exiting the switch block after executing matched case statements.
- Default cases do not require a break since they conclude the switch logic. This ensures only relevant outputs are printed based on user input.
Introduction to Loops in Java
- The need for loops arises when repetitive tasks must be performed without writing extensive code. Loops allow efficient execution of repeated actions.
- Three types of loops are identified:
for,do while, andwhile. Each serves different scenarios depending on how many times an action needs to repeat.
For Loop Syntax Explained
- The syntax of a
for loopincludes initialization (e.g., setting an index variable), condition checking (e.g., whether the index is less than or equal to 100), and incrementing/decrementing operations within its structure.
Understanding Loop Structures in Programming
For Loops: Basics and Implementation
- The discussion begins with the initialization of a loop variable
I, starting from 1, and incrementing it by 1 using the unary operator++. This allows the loop to run untilIreaches 100.
- Inside the loop, each value of
Iis printed sequentially. The output will display numbers from 1 to 100 as the loop iterates.
- The speaker emphasizes that if we want to print numbers in reverse (from 100 down to 1), we need to adjust our approach by initializing
Iat 100 and decrementing it instead.
Transitioning to While Loops
- A transition is made from for loops to while loops, explaining that a while loop continues executing as long as its condition remains true.
- To implement a countdown from 100 using a while loop,
Imust be declared and initialized outside of the loop. The condition checks ifIis greater than or equal to 1 before printing.
- It’s clarified that declaring variables within different scopes (like inside loops) prevents conflicts with previously declared variables. Thus, new names can be used for clarity.
Complete While Loop Structure
- The complete structure of a while loop includes initialization, condition checking, execution of code (printing), and decrementing the variable after each iteration.
- After commenting out the previous for loop code, running this while loop yields similar results—counting down from 100 to 1 effectively.
Nested While Loops
- An introduction to nested while loops indicates that conditions are checked before executing inner code blocks.
- In this example, another variable
Kis introduced for counting down within an outer while structure. Each iteration prints values until reaching one.
Conclusion on Loop Structures
How to Implement a Loop for User Input
Setting Up the Loop
- The program will continuously accept positive numbers from the user until a non-positive number (zero or negative) is entered, which will terminate the loop.
- A
Scannerclass is initialized to read input fromSystem.in, allowing user interaction for number input.
Loop Logic and Output
- A
whileloop is established with the condition that it continues as long as the input number is greater than or equal to zero.
- The variable for storing user input must be declared outside of the loop to avoid scope issues, ensuring it can be accessed correctly within the loop.
Handling User Input
- Upon entering a valid positive integer, such as 2 or 5, those numbers are printed on screen. If a negative number like -1 is entered, it indicates termination of the process with an exit code of zero.
Understanding Break and Continue Keywords
Introduction to Control Flow Keywords
- The discussion shifts towards two important keywords in programming:
breakandcontinue, which control flow within loops.
- The keyword
breakexits out of a loop entirely, whilecontinueallows skipping to the next iteration without terminating the loop.
Infinite Loops and Conditions
- An infinite loop can be created using a condition that always evaluates to true. To stop this loop, one must implement a break statement based on certain conditions.
- A variable
iis introduced starting at 0; if its value exceeds 5 during iterations, the break statement will terminate the loop.
Printing Values with Conditions
- As values are printed from 0 through 5, when
ibecomes greater than 5 (specifically when it reaches 6), execution breaks out of the loop.
Implementing Special Conditions in Loops
Adding Conditional Logic
- To enhance functionality, additional conditions can be added; for instance, if encountering a specific value like 3 during iterations should trigger special handling without breaking out of the entire loop.
Understanding Loop Control: Break and Continue Keywords
The Role of continue in Loops
- The discussion begins with the explanation of how certain statements in a loop can be skipped using the
continuekeyword, allowing the loop to proceed to the next iteration.
- It is emphasized that if a condition (e.g., when
iequals 3) triggerscontinue, it prevents reaching subsequent code for that iteration, effectively skipping over specific values.
- The output of the code example demonstrates that numbers are printed sequentially except for 3, which is omitted due to the use of
continue.
Understanding Loop Behavior
- When
ireaches 4 after skipping 3, it continues executing without interruption until it exceeds a defined limit (in this case, greater than 5).
- The importance of both
breakandcontinuekeywords is highlighted as essential tools for controlling loop execution flow.
Exception Handling Basics
- Transitioning from loops to error management, exceptions are introduced as mistakes in code that can disrupt execution but can be caught and handled gracefully.
- Unlike errors that halt program execution entirely, exceptions allow other parts of the program to run even when an issue arises.
Distinguishing Errors from Exceptions
- A practical example illustrates how a database error might cause part of a website to fail while allowing other components to function normally.
- Key terms like "try" and "catch" are introduced as mechanisms for handling exceptions within Java programming.
Implementing Try-Catch Blocks
- The structure of try-catch blocks is explained; all potentially problematic statements should be placed within a try block. If an exception occurs, control passes to the catch block where it can be managed.
Understanding Exception Handling and Method Creation in Java
Exception Handling Basics
- The discussion begins with the concept of exception handling in Java, emphasizing the importance of catching exceptions using a
catchblock after atryblock.
- It is highlighted that once an exception is caught, subsequent statements can still execute, demonstrating how proper exception handling allows for continued program flow.
Understanding Methods and Functions
- The speaker explains the difference between methods (in classes) and functions (in programming), using relatable analogies like thermometers to illustrate input-output operations.
- Examples such as volume buttons on phones are used to explain how methods take inputs (like button presses) and produce outputs (like increased volume).
Creating Methods in Java
- The necessity of creating methods for repetitive tasks is discussed; if similar code appears multiple times, it should be encapsulated within a method to enhance efficiency.
- A practical example is provided where "Hello Java" is printed repeatedly. Instead of repeating code, a method named
printJavais created.
Defining Method Characteristics
- When defining methods, keywords like
public,static, and return types must be specified. For instance, the methodprintJavadoes not require any input or return value.
- The structure of calling a function involves writing its name followed by parentheses. This process mirrors pressing buttons on devices to trigger actions.
Implementing Input Parameters in Methods
- Further elaboration on method definitions includes specifying input parameters. For example, a new method could accept a string parameter representing a name to print it out.
- The speaker emphasizes passing arguments into methods when calling them. This showcases how dynamic inputs can alter output based on user-defined values.
Understanding Functions and Methods in Programming
Introduction to Functions
- The speaker discusses the concept of printing names using functions, emphasizing that if we want to print different names repeatedly, we can create a function that accepts input parameters.
Input Handling in Functions
- When dealing with multiple inputs, the speaker explains how to separate them using commas. For example, two integers can be passed as inputs for processing.
Performing Calculations
- The process of summing two numbers is introduced. The speaker describes creating a new variable to store the sum of two integers (a + b) and then printing this result.
Main Function Characteristics
- The main function is described as having a string type for arguments and being void (not returning any value). It serves as an entry point for executing code.
Exploring Methods Through Practice
- The importance of practicing various methods and concepts is highlighted. Engaging with different operations will enhance understanding of programming principles.
Mini Project: Number Guessing Game
Project Overview
- A mini project is introduced where users will guess a randomly generated number. Feedback will be provided based on whether their guesses are too high or too low.
Random Number Generation
- The project begins by generating a random number between 1 and 100 using the Math class's random function, which produces decimal values multiplied by 100 for integer conversion.
User Interaction Loop
- A while loop is implemented to prompt users to guess the number. User input is captured through the Scanner class, allowing interaction with the program.
Conditional Logic for Feedback
- Three conditions are established: if the user's guess matches the random number, feedback indicates correctness; otherwise, it informs whether their guess was too high or too low.
Finalizing User Input Conditions
Number Guessing Game Implementation
Overview of the Code Structure
- The code begins with importing the Scanner class to facilitate user input.
- A random number is generated between 1 and 100, which the user must guess. The user's initial guess is set to zero.
User Input and Logic Flow
- A loop prompts the user for their guess, checking if it matches the randomly generated number. If correct, a success message is printed and the loop breaks.
- If the user's guess exceeds the target number, feedback is provided indicating that their guess was too high; similarly, negative inputs are handled appropriately within this logic structure.
Gameplay Example
- The game starts with an upper limit of 100; users are encouraged to make guesses based on feedback received from previous attempts (e.g., guessing lower or higher).
- An example sequence shows how guesses evolve: starting at 50, then adjusting upwards through various numbers until narrowing down to the correct answer of 84 after several iterations.
Conclusion and Learning Outcomes