Java Control Flow If-Else Statement in Java Introduction So far, we've been writing programs that follow one instruction after another in a sequence. But in many cases, we might need to skip certain instructions and execute others to solve a problem, this is where we required control flow statements. A real life example of the
Java Control Flow Making Logical Decisions in Programming: Comparing Values and Variables Introduction In programming, the comparison of values and variables plays a crucial role in making decisions and building logical structures. To illustrate, imagine a scenario where we have to evaluate whether a student has passed or failed an examination. This evaluation will require comparing the student's achieved score
Building Blocks in Java User Input in Java Learning how to get user input in Java helps you make programs that can talk to people. It's like teaching your program to understand what people want, so you can make your programs work better for them. So far, we've been directly assigning values to variables
Building Blocks in Java Type Conversion in Java In Java, we work with different types of data. We have: * int for numbers without decimal points, like 5 or -6. * double for numbers with decimal points, like -5.6 or 7.84. * char for single characters, like 'a' or '1'. Sometimes, we need to change
Building Blocks in Java Multiple Operators in Java So far, we've only used one operator at a time in our expressions. But there might be cases where we need to use multiple operators in a single line. Let’s look at an example - class Main { public static void main(String[] args) { int x = 6 / 2
Building Blocks in Java Arithmetic Operators in Java Alright, let's talk about Arithmetic Operators! These special tools help us do math operations like adding, subtracting, multiplying, dividing, and finding remainders. Here's what we're going to explore in this lesson: Operators Operations + Addition - Subtraction * Multiplication / Division % Remainder after division (Modulo) Addition Operator
Building Blocks in Java Operators in Java So far, we've been working with literal values and variables, but in real projects, we often need to perform operations with them. Today, we'll explore operators! These special symbols let us do cool things like adding, subtracting, and more with our values and variables. You might
Building Blocks in Java Data Types in Java In Java, each type of data (such as integer, character, decimal, boolean, and so forth) is predefined as part of the programming language and all constants or variables defined for a given program must be described with one of the data types. It determines the type of data associated with
Building Blocks in Java How to Print in Java? Print numbers or text in Java In Java, when we write programs, we often want to display information on the screen for the user to see. To do this, we use the System.out.println(); statement. For example, if we want to display a number, like 5, on the screen,
Building Blocks in Java Variables in Java , In the last lesson, we familiarise ourselves with literals. Nevertheless, In real-life problems, we may often require the storage of data for future use. For this, we use something called Variables. Think of a variable as a box where you can keep things like numbers or words. These boxes can
Building Blocks in Java Literals in Java Literals In programming, we can use some fixed values/constants in our code. These fixed values are called Literals. These values are not variables or expressions but are constants that retain their fixed value throughout the program. Types of Literals In Java, some common types of literals are: * Integers (int)
Building Blocks in Java Comments and Statements in Java Introduction to Comments In programming, we can instruct computers to ignore some parts of the code by using comments. Why use comments if the computer ignores them? We use comments as little notes in our program to help us understand the code better. They're mainly for humans to