{
  "Java Introduction": [
    {
      "title": "Introduction to Java",
      "description": "Java is a general-purpose language, and portability was baked into it from the start (that's the whole \"write once, run anywhere\" idea). It grew out of a real need for software that didn't care what platform it was running on. It supports data abstraction, object-oriented programming, and generic programming.",
      "sub_description": "James Gosling and his team at Sun Microsystems built it, and it went public in 1995.",
      "additional_info": "The biggest thing to happen to Java after its first decade was probably the Java Collections Framework, the standard library's toolkit for containers and algorithms. Joshua Bloch gets most of the credit as its main architect.",
      "content": [
        {
          "type": "heading",
          "level": 2,
          "text": "The Basics"
        },
        {
          "type": "paragraph",
          "text": "To get a computer to do anything, you have to tell it exactly what to do, step by step. That description is called a program, and programming is just writing and testing one."
        },
        {
          "type": "heading",
          "level": 2,
          "text": "First Program"
        },
        {
          "type": "textarea",
          "text": "//This program outputs the message \"Hello World!\" to the monitor.\npublic class Main {\n    public static void main(String[] args) {\n        System.out.println(\"Hello World!\");\n    }\n}"
        },
        {
          "type": "paragraph",
          "text": "Run it and you'll see Hello World! printed, followed by a newline. String literals in Java sit between double quotes (\"). \\n is a special character. It means \"start a new line.\""
        },
        {
          "type": "heading",
          "level": 2,
          "text": "Java Syntax, line by line"
        },
        {
          "type": "list",
          "items": [
            "<b>public class Main</b> — every application needs a class, and the class name has to match the file name (so, Main.java).",
            "<b>public static void main(String[] args)</b> is the main method. Every Java program needs one, since it's where execution actually starts.",
            "<b>System.out.println()</b> prints a line of text to the screen.",
            "Java is case-sensitive, so Main and main are two different identifiers, not typos of each other.",
            "Statements end with a semicolon. Always.",
            "Curly braces { } wrap the body of a class, method, loop, or condition."
          ]
        },
        {
          "type": "heading",
          "level": 2,
          "text": "Why Learn Java?"
        },
        {
          "type": "list",
          "items": [
            "<b>Platform Independent:</b> Runs on Windows, Mac, Linux, you name it. \"Write once, run anywhere\" isn't just marketing.",
            "<b>Widely Used:</b> It's one of the most widely used languages around, full stop.",
            "<b>Large Community:</b> Big community. Tons of libraries already built for you.",
            "<b>Object-Oriented:</b> It's object-oriented, so your code tends to end up organized instead of a mess.",
            "<b>Easy to Learn:</b> Honestly, it's not that hard to pick up."
          ]
        }
      ]
    },
    {
      "title": "Comments in Java",
      "description": "Comments describe what the program is supposed to do, or just leave notes for whoever reads the code next. The compiler skips them completely, they're purely for humans.",
      "sub_description": "Comments are ignored by the compiler and are only meant for humans to understand the logic, purpose, or function of the code.",
      "content": [
        {
          "type": "heading",
          "level": 3,
          "text": "Single-Line Comment"
        },
        {
          "type": "paragraph",
          "text": "A single-line comment starts with // and continues to the end of the line. It tells whoever's reading what the program does."
        },
        {
          "type": "textarea",
          "text": "// Single-line comment\n//This program outputs the message \"Hello World!\" to the monitor."
        },
        {
          "type": "heading",
          "level": 3,
          "text": "Multi-Line Comment"
        },
        {
          "type": "textarea",
          "text": "/*\n * Multi-line comment\n * can span several lines\n */"
        },
        {
          "type": "heading",
          "level": 3,
          "text": "The public class Main Declaration"
        },
        {
          "type": "paragraph",
          "text": "This line declares a class called Main. In Java, code always lives inside a class, and the file name has to match the public class name — Main.java in this case. Here we're using the standard output stream, System.out, and its println() method."
        },
        {
          "type": "heading",
          "level": 3,
          "text": "How does a computer know where to start?"
        },
        {
          "type": "paragraph",
          "text": "It looks for a method called main and starts running from there. Every Java program needs a method named main, with exactly this signature: public static void main(String[] args). That's how it knows where to start."
        }
      ]
    },
    {
      "title": "Input in Java",
      "description": "Most real programs don't just repeat the same thing every time. They react to whatever input you feed them.",
      "sub_description": "To read something in, you need a place to put it — somewhere in memory to hold what was read. That's a variable.",
      "content": [
        {
          "type": "heading",
          "level": 2,
          "text": "Reading Input with Scanner"
        },
        {
          "type": "textarea",
          "text": "import java.util.Scanner;\n \npublic class Main {\n    public static void main(String[] args) {\n        Scanner sc = new Scanner(System.in);\n        int age;\n        System.out.print(\"Enter age: \");\n        age = sc.nextInt();\n        System.out.println(\"Age is \" + age);\n    }\n}"
        },
        {
          "type": "heading",
          "level": 3,
          "text": "Scanner Methods Worth Knowing"
        },
        {
          "type": "list",
          "items": [
            "<b>nextInt()</b> reads an int",
            "<b>nextDouble()</b> reads a double",
            "<b>nextLine()</b> reads a whole line as a String",
            "<b>next()</b> reads a single word, up to the next space"
          ]
        }
      ]
    }
  ],
  "Basic Syntax, Variables & Data Types": [
    {
      "title": "Variables in Java",
      "description": "The \"places\" where data lives are technically called objects, though most people just say variables. To reach one you need a name, and a named object is a variable with a specific type, like int or String.",
      "sub_description": "Variables allow Java programs to store and manipulate data during execution. Every variable must be declared with a type before it can be used.",
      "content": [
        {
          "type": "heading",
          "level": 2,
          "text": "Declaring and Naming Multiple Variables"
        },
        {
          "type": "textarea",
          "text": "int x, y, z;      // declare three variables of the same type\nx = 10;\ny = 20;\nz = x + y;         // 30\n \nint a = 1, b = 2, c = 3; // declare and assign in one line"
        },
        {
          "type": "heading",
          "level": 4,
          "text": "Declaration Statement"
        },
        {
          "type": "textarea",
          "text": "int x, y, z; //declare three integer type variables."
        },
        {
          "type": "heading",
          "level": 4,
          "text": "Initialization Statement"
        },
        {
          "type": "textarea",
          "text": "x = 10;  // initialize value of x with 10\ny = 20; // initialize value of y with 20"
        },
        {
          "type": "heading",
          "level": 4,
          "text": "Expression Statement"
        },
        {
          "type": "textarea",
          "text": "z = x + y; //computation"
        },
        {
          "type": "heading",
          "level": 2,
          "text": "Constant Expressions"
        },
        {
          "type": "paragraph",
          "text": "Programs use constants all the time, pi in a geometry program, or a fixed conversion factor like 2.54 for inches to centimeters. Once you've set one, you can't change it later."
        },
        {
          "type": "textarea",
          "text": "final double PI = 3.14159;\nPI = 7; // error: cannot assign a value to final variable PI"
        }
      ]
    },
    {
      "title": "Keywords and Identifiers in Java",
      "description": "When writing programs, we use words and names to define actions and store data. These words fall into two categories: keywords and identifiers.",
      "sub_description": "Keywords are reserved words with predefined meanings in Java. Identifiers are user-defined names for variables, methods, classes, and other program elements.",
      "content": [
        {
          "type": "heading",
          "level": 2,
          "text": "What are Identifiers?"
        },
        {
          "type": "paragraph",
          "text": "An identifier is just the name you give something in your program — a variable, method, class, whatever — so it can be distinguished from everything else."
        },
        {
          "type": "heading",
          "level": 4,
          "text": "Rules Identifiers Must Follow"
        },
        {
          "type": "list",
          "items": [
            "Only letters (A-Z, a-z), digits (0-9), underscores (_), and the dollar sign ($)",
            "Has to start with a letter, underscore, or dollar sign — never a digit",
            "Can't be a reserved keyword (int, while, return, class, and so on are off-limits)",
            "Case matters, so total and Total count as two different identifiers"
          ]
        },
        {
          "type": "heading",
          "level": 2,
          "text": "What are Keywords?"
        },
        {
          "type": "paragraph",
          "text": "Keywords are reserved words with a fixed meaning to the compiler. You can't reuse one as an identifier."
        },
        {
          "type": "heading",
          "level": 4,
          "text": "Common Java Keywords"
        },
        {
          "type": "list",
          "items": [
            "int, float, return, class, public, private",
            "if, else, while, for, break, continue",
            "void, this, new, try, catch, throw, final, static",
            "etc..."
          ]
        }
      ]
    },
    {
      "title": "Data Types in Java",
      "description": "Java gives you a solid set of built-in primitive types plus user-defined reference types.",
      "sub_description": "Unlike C++, Java's primitive types have a fixed size no matter what platform you're running on, so there's no need for a sizeof() operator. The size just never changes.",
      "content": [
        {
          "type": "heading",
          "level": 2,
          "text": "Data Type Sizes in Java"
        },
        {
          "type": "textarea",
          "text": "public class Main {\n    public static void main(String[] args) {\n        System.out.println(\"Size of char : 2 bytes\");\n        System.out.println(\"Size of int : 4 bytes\");\n        System.out.println(\"Size of short : 2 bytes\");\n        System.out.println(\"Size of long : 8 bytes\");\n        System.out.println(\"Size of float : 4 bytes\");\n        System.out.println(\"Size of double : 8 bytes\");\n    }\n}"
        },
        {
          "type": "paragraph",
          "text": "Every line here gets printed with println(), which tacks a newline onto the end automatically, and the + operator is stitching several values together on screen. Since the language spec fixes Java's primitive sizes rather than the platform, we can just state them directly."
        },
        {
          "type": "heading",
          "level": 2,
          "text": "The Eight Primitive Data Types"
        },
        {
          "type": "list",
          "items": [
            "<b>byte</b> — 1 byte, whole numbers from -128 to 127",
            "<b>short</b> — 2 bytes, whole numbers from -32,768 to 32,767",
            "<b>int</b> — 4 bytes, whole numbers from -2^31 to 2^31-1",
            "<b>long</b> — 8 bytes, whole numbers, for when int just isn't big enough (add an L suffix)",
            "<b>float</b> — 4 bytes, decimals, good for about 6-7 digits of precision (add an f suffix)",
            "<b>double</b> — 8 bytes, decimals, good for about 15 digits of precision",
            "<b>boolean</b> — 1 bit, just true or false",
            "<b>char</b> — 2 bytes, a single character or ASCII value, written in single quotes"
          ]
        },
        {
          "type": "heading",
          "level": 2,
          "text": "Non-Primitive (Reference) Data Types"
        },
        {
          "type": "paragraph",
          "text": "Beyond the primitives, Java also has reference types: String, arrays, classes, interfaces. The difference is reference variables get created through a constructor, and they can be set to null."
        },
        {
          "type": "textarea",
          "text": "String name = \"Java\";\nint[] numbers = {1, 2, 3};"
        }
      ]
    },
    {
      "title": "Type Casting in Java",
      "description": "Type casting just means converting a value from one type to another. Java has two kinds: widening (automatic) and narrowing (manual).",
      "sub_description": "Widening casting happens automatically when going from a smaller type to a larger one. Narrowing casting must be done explicitly with parentheses.",
      "content": [
        {
          "type": "heading",
          "level": 2,
          "text": "Types of Casting"
        },
        {
          "type": "list",
          "items": [
            "<b>Widening casting (automatic):</b> going from a smaller type to a bigger one (byte -> short -> char -> int -> long -> float -> double)",
            "<b>Narrowing casting (manual):</b> going from a bigger type to a smaller one, which you have to do explicitly with parentheses"
          ]
        },
        {
          "type": "textarea",
          "text": "public class Main {\n    public static void main(String[] args) {\n        int myInt = 9;\n        double myDouble = myInt; // Widening: automatic\n        System.out.println(myInt);    // 9\n        System.out.println(myDouble); // 9.0\n \n        double myDouble2 = 9.78;\n        int myInt2 = (int) myDouble2; // Narrowing: manual\n        System.out.println(myDouble2); // 9.78\n        System.out.println(myInt2);    // 9\n    }\n}"
        }
      ]
    }
  ],
  "Operators and Expressions in Java": [
    {
      "title": "Operators in Java",
      "description": "Operators perform operations on variables and values. Java splits its operators into a few groups.",
      "sub_description": "Understanding operators is essential to writing expressions, making calculations, comparing values, and controlling program logic.",
      "content": [
        {
          "type": "heading",
          "level": 2,
          "text": "Types of Operators in Java"
        },
        {
          "type": "list",
          "items": [
            "Arithmetic operators",
            "Assignment operators",
            "Comparison operators",
            "Logical operators",
            "Bitwise operators"
          ]
        },
        {
          "type": "heading",
          "level": 2,
          "text": "Arithmetic Operators"
        },
        {
          "type": "paragraph",
          "text": "Arithmetic operators cover the usual math operations."
        },
        {
          "type": "textarea",
          "text": "public class Main {\n    public static void main(String[] args) {\n        int x = 10;\n        int y = 3;\n \n        System.out.println(x + y); // 13\n        System.out.println(x - y); // 7\n        System.out.println(x * y); // 30\n        System.out.println(x / y); // 3 (integer division)\n        System.out.println(x % y); // 1\n \n        int z = 5;\n        ++z;\n        System.out.println(z); // 6\n        --z;\n        System.out.println(z); // 5\n    }\n}"
        },
        {
          "type": "heading",
          "level": 2,
          "text": "Assignment Operators"
        },
        {
          "type": "paragraph",
          "text": "Assignment operators assign values to variables, and they can be combined with an operation to do both at once."
        },
        {
          "type": "textarea",
          "text": "x = 10;   // x = 10\nx += 5;   // x = x + 5\nx -= 5;   // x = x - 5\nx *= 5;   // x = x * 5\nx /= 5;   // x = x / 5\nx %= 5;   // x = x % 5"
        },
        {
          "type": "heading",
          "level": 2,
          "text": "Comparison Operators"
        },
        {
          "type": "paragraph",
          "text": "Comparison operators compare two values and hand back a boolean, true or false."
        },
        {
          "type": "list",
          "items": [
            "==   equal to",
            "!=   not equal",
            ">    greater than",
            "<    less than",
            ">=   greater than or equal to",
            "<=   less than or equal to"
          ]
        },
        {
          "type": "heading",
          "level": 2,
          "text": "Logical Operators"
        },
        {
          "type": "paragraph",
          "text": "Logical operators combine boolean expressions or flip them."
        },
        {
          "type": "list",
          "items": [
            "<b>&amp;&amp;</b>   Logical AND - returns true if both statements are true",
            "<b>||</b>   Logical OR - returns true if one of the statements is true",
            "<b>!</b>    Logical NOT - reverses the result"
          ]
        },
        {
          "type": "heading",
          "level": 2,
          "text": "Increment and Decrement Operators"
        },
        {
          "type": "paragraph",
          "text": "The increment operator ++ adds 1 to whatever it's applied to. The decrement operator -- subtracts 1."
        },
        {
          "type": "list",
          "items": [
            "x = x + 1; is the same as x++;",
            "x = x - 1; is the same as x--;"
          ]
        },
        {
          "type": "heading",
          "level": 4,
          "text": "Pre-Increment vs Post-Increment"
        },
        {
          "type": "list",
          "items": [
            "<b>Pre-increment (++x)</b> — increments the value before it is used in an expression.",
            "<b>Post-increment (x++)</b> — uses the current value in the expression, then increments."
          ]
        },
        {
          "type": "textarea",
          "text": "public class Main {\n    public static void main(String[] args) {\n        int a = 10, b = 10;\n \n        System.out.println(\"Before: a = \" + a + \" b = \" + b);\n        System.out.println(\"++a = \" + (++a));  // Pre-increment\n        System.out.println(\"b++ = \" + (b++));  // Post-increment\n        System.out.println(\"After: a = \" + a + \" b = \" + b);\n    }\n}"
        },
        {
          "type": "heading",
          "level": 4,
          "text": "Pre-Decrement vs Post-Decrement"
        },
        {
          "type": "list",
          "items": [
            "<b>Pre-decrement (--x)</b> — decrements the value before it is used in an expression.",
            "<b>Post-decrement (x--)</b> — uses the current value in the expression, then decrements."
          ]
        },
        {
          "type": "textarea",
          "text": "public class Main {\n    public static void main(String[] args) {\n        int a = 10, b = 10;\n \n        System.out.println(\"Before: a = \" + a + \" b = \" + b);\n        System.out.println(\"--a = \" + (--a));  // Pre-decrement\n        System.out.println(\"b-- = \" + (b--));  // Post-decrement\n        System.out.println(\"After: a = \" + a + \" b = \" + b);\n    }\n}"
        }
      ]
    }
  ],
  "Strings and Math in Java": [
    {
      "title": "Strings in Java",
      "description": "The String type stores text — a sequence of characters — and it has to be wrapped in double quotes.",
      "sub_description": "Java's String class provides many built-in methods for common text operations like searching, slicing, and case conversion.",
      "content": [
        {
          "type": "textarea",
          "text": "public class Main {\n    public static void main(String[] args) {\n        String greeting = \"Hello\";\n        System.out.println(greeting);\n    }\n}"
        },
        {
          "type": "heading",
          "level": 2,
          "text": "String Concatenation"
        },
        {
          "type": "paragraph",
          "text": "The + operator glues strings together, or combines a string with some other type of value."
        },
        {
          "type": "textarea",
          "text": "String firstName = \"John\";\nString lastName = \"Doe\";\nSystem.out.println(firstName + \" \" + lastName); // John Doe"
        },
        {
          "type": "heading",
          "level": 2,
          "text": "Common String Methods"
        },
        {
          "type": "list",
          "items": [
            "<b>length()</b> gives you the length of the string",
            "<b>toUpperCase() / toLowerCase()</b> switch the case",
            "<b>indexOf(\"x\")</b> finds where a character or substring first shows up",
            "<b>charAt(i)</b> grabs the character at a given index",
            "<b>substring(start, end)</b> pulls out part of the string",
            "<b>equals()</b> checks if two strings have the same content (don't use == for this)"
          ]
        },
        {
          "type": "textarea",
          "text": "String txt = \"Hello World\";\nSystem.out.println(txt.length());          // 11\nSystem.out.println(txt.toUpperCase());      // HELLO WORLD\nSystem.out.println(txt.indexOf(\"World\"));  // 6"
        }
      ]
    },
    {
      "title": "Math Class in Java",
      "description": "The Math class comes with a bunch of methods for doing math on numbers.",
      "sub_description": "Java's built-in Math class provides static methods for common mathematical operations without needing any imports.",
      "content": [
        {
          "type": "heading",
          "level": 2,
          "text": "Useful Math Methods"
        },
        {
          "type": "list",
          "items": [
            "<b>Math.max(x, y):</b> whichever value is bigger",
            "<b>Math.min(x, y):</b> whichever value is smaller",
            "<b>Math.sqrt(x):</b> square root of x",
            "<b>Math.abs(x):</b> absolute value of x",
            "<b>Math.random():</b> a random number between 0.0 (inclusive) and 1.0 (exclusive)"
          ]
        },
        {
          "type": "textarea",
          "text": "System.out.println(Math.max(5, 10));  // 10\nSystem.out.println(Math.sqrt(64));    // 8.0\nSystem.out.println(Math.abs(-4.7));   // 4.7"
        }
      ]
    },
    {
      "title": "Booleans in Java",
      "description": "A lot of the time you just need something that's one of two values, true or false. That's what boolean is for.",
      "sub_description": "Boolean values are the foundation of all conditional logic in Java — if statements, while loops, and comparisons all rely on them.",
      "content": [
        {
          "type": "textarea",
          "text": "boolean isJavaFun = true;\nboolean isFishTasty = false;\nSystem.out.println(isJavaFun);     // true\nSystem.out.println(10 > 9);        // true"
        }
      ]
    }
  ],
  "Control Flow in Java": [
    {
      "title": "Conditional Statements in Java",
      "description": "Java supports the usual logical conditions from math class. Conditional statements let a program make decisions and execute different code depending on whether a condition is true or false.",
      "sub_description": "Java provides if, else if, else, and switch to control program flow based on conditions.",
      "content": [
        {
          "type": "heading",
          "level": 2,
          "text": "Types of Conditionals"
        },
        {
          "type": "list",
          "items": [
            "<b>if</b> runs a block of code when a condition is true",
            "<b>else</b> runs a block when that condition turns out false",
            "<b>else if</b> lets you check another condition if the first one failed",
            "<b>switch</b> picks one out of several possible code blocks"
          ]
        },
        {
          "type": "heading",
          "level": 2,
          "text": "if / else if / else"
        },
        {
          "type": "textarea",
          "text": "public class Main {\n    public static void main(String[] args) {\n        int time = 20;\n        if (time < 10) {\n            System.out.println(\"Good morning.\");\n        } else if (time < 20) {\n            System.out.println(\"Good day.\");\n        } else {\n            System.out.println(\"Good evening.\");\n        }\n    }\n}"
        },
        {
          "type": "heading",
          "level": 2,
          "text": "Ternary Operator"
        },
        {
          "type": "paragraph",
          "text": "The ternary operator is a shorthand for a simple if-else: variable = (condition) ? expressionTrue : expressionFalse;"
        },
        {
          "type": "textarea",
          "text": "int time = 20;\nString result = (time < 18) ? \"Good day.\" : \"Good evening.\";\nSystem.out.println(result); // Good evening."
        },
        {
          "type": "heading",
          "level": 2,
          "text": "Switch Statement"
        },
        {
          "type": "paragraph",
          "text": "The switch statement is a cleaner way to pick between several code blocks instead of chaining a pile of if..else statements. break stops the switch block as soon as it finds a match. Skip it, and execution just falls through to the next case."
        },
        {
          "type": "textarea",
          "text": "public class Main {\n    public static void main(String[] args) {\n        int day = 4;\n        switch (day) {\n            case 1:\n                System.out.println(\"Monday\");\n                break;\n            case 2:\n                System.out.println(\"Tuesday\");\n                break;\n            case 3:\n                System.out.println(\"Wednesday\");\n                break;\n            case 4:\n                System.out.println(\"Thursday\");\n                break;\n            default:\n                System.out.println(\"Another day\");\n        }\n    }\n}"
        }
      ]
    },
    {
      "title": "Loops in Java",
      "description": "Loops repeat a chunk of your program some number of times. They keep going while a condition is true, and stop the moment it isn't.",
      "sub_description": "Java has three kinds of loops: for, while, and do-while. There is also a for-each loop for iterating over arrays and collections.",
      "content": [
        {
          "type": "heading",
          "level": 2,
          "text": "For Loop"
        },
        {
          "type": "paragraph",
          "text": "The for loop is probably the easiest one to get your head around — everything controlling it sits in one place."
        },
        {
          "type": "heading",
          "level": 4,
          "text": "Syntax"
        },
        {
          "type": "textarea",
          "text": "for (initialization; condition; increment/decrement)\n{\n    //statement\n}"
        },
        {
          "type": "heading",
          "level": 4,
          "text": "Example 1: Print 1 2 3 4 5"
        },
        {
          "type": "textarea",
          "text": "for (i = 1; i <= 5; i++)\n{\n    System.out.print(i + \" \");\n}"
        },
        {
          "type": "heading",
          "level": 4,
          "text": "Example 2: Print Even Numbers — 2 4 6 8 10"
        },
        {
          "type": "textarea",
          "text": "for (int i = 2; i <= 10; i = i + 2)\n{\n    System.out.print(i + \" \");\n}"
        },
        {
          "type": "heading",
          "level": 4,
          "text": "Example 3: Print in Reverse — 5 4 3 2 1"
        },
        {
          "type": "textarea",
          "text": "for (int i = 5; i >= 1; i--)\n{\n    System.out.print(i + \" \");\n}"
        },
        {
          "type": "heading",
          "level": 4,
          "text": "Example 4: Print Multiplication Table of 2"
        },
        {
          "type": "paragraph",
          "text": "Desired output: 2 x 1 = 2, 2 x 2 = 4, 2 x 3 = 6 ..."
        },
        {
          "type": "textarea",
          "text": "public class Main {\n    public static void main(String[] args) {\n        int a = 2, c = 0;\n        for (int i = 1; i <= 10; i++)\n        {\n            c = a * i;\n            System.out.println(a + \" x \" + i + \" = \" + c);\n        }\n    }\n}"
        },
        {
          "type": "heading",
          "level": 2,
          "text": "While Loop"
        },
        {
          "type": "paragraph",
          "text": "The while loop runs a block of code as long as some condition stays true, and it checks that condition before every single iteration."
        },
        {
          "type": "textarea",
          "text": "public class Main {\n    public static void main(String[] args) {\n        int i = 0;\n        while (i < 5) {\n            System.out.println(i);\n            i++;\n        }\n    }\n}"
        },
        {
          "type": "heading",
          "level": 2,
          "text": "Do-While Loop"
        },
        {
          "type": "paragraph",
          "text": "do-while is a close cousin to while. The difference: it runs the code block once first, before checking the condition, then keeps going as long as that condition holds."
        },
        {
          "type": "textarea",
          "text": "public class Main {\n    public static void main(String[] args) {\n        int i = 0;\n        do {\n            System.out.println(i);\n            i++;\n        } while (i < 5);\n    }\n}"
        },
        {
          "type": "heading",
          "level": 2,
          "text": "For-Each Loop"
        },
        {
          "type": "paragraph",
          "text": "There's also a \"for-each\" loop, built just for looping through elements in an array or collection."
        },
        {
          "type": "textarea",
          "text": "String[] cars = {\"Volvo\", \"BMW\", \"Ford\", \"Mazda\"};\nfor (String car : cars) {\n    System.out.println(car);\n}"
        },
        {
          "type": "heading",
          "level": 2,
          "text": "Break and Continue"
        },
        {
          "type": "list",
          "items": [
            "<b>break</b> exits the loop completely, then continues with whatever comes after it",
            "<b>continue</b> skips just the current iteration and jumps to the next one"
          ]
        },
        {
          "type": "textarea",
          "text": "for (int i = 0; i < 10; i++) {\n    if (i == 4) { break; }      // stops the loop at 4\n    System.out.println(i);\n}\n \nfor (int i = 0; i < 10; i++) {\n    if (i == 4) { continue; }   // skips printing 4\n    System.out.println(i);\n}"
        }
      ]
    }
  ],
  "Arrays in Java": [
    {
      "title": "Arrays in Java",
      "description": "Arrays let you store several values of the same type under one variable, instead of a separate variable for every single value.",
      "sub_description": "Arrays are fixed in size once created. For resizable collections, use ArrayList from the Java Collections Framework.",
      "content": [
        {
          "type": "textarea",
          "text": "public class Main {\n    public static void main(String[] args) {\n        String[] cars = {\"Volvo\", \"BMW\", \"Ford\", \"Mazda\"};\n        System.out.println(cars[0]); // Volvo\n        cars[0] = \"Opel\";           // change the first element\n        System.out.println(cars.length); // 4\n    }\n}"
        },
        {
          "type": "heading",
          "level": 2,
          "text": "Multidimensional Arrays"
        },
        {
          "type": "paragraph",
          "text": "A multidimensional array is basically an array of arrays. Usually used for tables or grids of values."
        },
        {
          "type": "textarea",
          "text": "int[][] grid = {\n    {1, 2, 3},\n    {4, 5, 6}\n};\nSystem.out.println(grid[1][2]); // 6"
        }
      ]
    }
  ],
  "Methods in Java": [
    {
      "title": "Methods in Java",
      "description": "A method is a chunk of code that only runs when it's called. They exist so you're not stuck repeating the same code over and over.",
      "sub_description": "Methods help organize code into reusable blocks and are the building blocks of object-oriented programming in Java.",
      "content": [
        {
          "type": "textarea",
          "text": "public class Main {\n    static void myMethod() {\n        System.out.println(\"I just got executed!\");\n    }\n \n    public static void main(String[] args) {\n        myMethod();\n    }\n}"
        },
        {
          "type": "heading",
          "level": 2,
          "text": "Parameters and Arguments"
        },
        {
          "type": "paragraph",
          "text": "You can pass information into methods as parameters. Inside the method they just act like regular variables, and you separate multiple ones with commas."
        },
        {
          "type": "textarea",
          "text": "static void greet(String name) {\n    System.out.println(\"Hello \" + name);\n}\n \npublic static void main(String[] args) {\n    greet(\"Ripun\");   // Hello Ripun\n    greet(\"Simran\");  // Hello Simran\n}"
        },
        {
          "type": "heading",
          "level": 2,
          "text": "Return Values"
        },
        {
          "type": "paragraph",
          "text": "void means the method doesn't return a value. Want it to return something? Swap void for a primitive type (int, double, etc.) and use return inside the method."
        },
        {
          "type": "textarea",
          "text": "static int add(int x, int y) {\n    return x + y;\n}\n \npublic static void main(String[] args) {\n    System.out.println(add(5, 3)); // 8\n}"
        },
        {
          "type": "heading",
          "level": 2,
          "text": "Method Overloading"
        },
        {
          "type": "paragraph",
          "text": "Method overloading lets several methods share a name as long as their parameters differ. Java figures out which one you meant based on the arguments you pass."
        },
        {
          "type": "textarea",
          "text": "static int plusMethod(int x, int y) {\n    return x + y;\n}\nstatic double plusMethod(double x, double y) {\n    return x + y;\n}\n \npublic static void main(String[] args) {\n    System.out.println(plusMethod(1, 2));       // 3\n    System.out.println(plusMethod(1.5, 2.5));   // 4.0\n}"
        }
      ]
    }
  ],
  "Object-Oriented Programming (OOP)": [
    {
      "title": "Object-Oriented Programming in Java",
      "description": "Java is object-oriented top to bottom — everything's built around classes and objects, each with its own attributes and methods. OOP rests on four pillars: encapsulation, inheritance, polymorphism, abstraction.",
      "sub_description": "OOP allows you to model real-world entities as objects, making code more modular, reusable, and easier to maintain.",
      "content": [
        {
          "type": "heading",
          "level": 2,
          "text": "Classes and Objects"
        },
        {
          "type": "paragraph",
          "text": "A class is a blueprint for building objects. An object is just an instance made from that blueprint."
        },
        {
          "type": "textarea",
          "text": "public class Main {\n    int x = 5; // an attribute\n \n    public static void main(String[] args) {\n        Main myObj = new Main(); // create an object\n        System.out.println(myObj.x);\n    }\n}"
        },
        {
          "type": "heading",
          "level": 2,
          "text": "Constructors"
        },
        {
          "type": "paragraph",
          "text": "A constructor is a special method that fires automatically whenever an object gets created, usually to set things up. It always shares the class's name."
        },
        {
          "type": "textarea",
          "text": "public class Car {\n    int modelYear;\n    String modelName;\n \n    public Car(int year, String name) { // constructor\n        modelYear = year;\n        modelName = name;\n    }\n \n    public static void main(String[] args) {\n        Car myCar = new Car(2020, \"Mustang\");\n        System.out.println(myCar.modelYear + \" \" + myCar.modelName);\n    }\n}"
        }
      ]
    },
    {
      "title": "Access Modifiers in Java",
      "description": "Access modifiers control the visibility of classes, methods, and variables. They are a key part of encapsulation in Java.",
      "sub_description": "Java has four access levels: public, private, protected, and default (package-private). Non-access modifiers like final, static, and abstract add additional behavior.",
      "content": [
        {
          "type": "heading",
          "level": 2,
          "text": "Access Modifiers"
        },
        {
          "type": "list",
          "items": [
            "<b>public:</b> reachable from any other class",
            "<b>private:</b> only reachable inside the class where it's declared",
            "<b>protected:</b> reachable within the same package, and by subclasses too",
            "<b>default (no keyword at all):</b> reachable only within the same package"
          ]
        },
        {
          "type": "heading",
          "level": 2,
          "text": "Non-Access Modifiers"
        },
        {
          "type": "list",
          "items": [
            "<b>final</b> locks a class/method/variable so it can't be changed or overridden",
            "<b>static</b> ties a member to the class itself, not any one object",
            "<b>abstract</b> means a class/method can't be used directly — a subclass has to implement it"
          ]
        }
      ]
    },
    {
      "title": "Encapsulation in Java",
      "description": "Encapsulation is about hiding a field's real value by marking it private, then giving controlled access to it through public get and set methods.",
      "sub_description": "Encapsulation protects the internal state of an object from outside interference and only exposes what is necessary.",
      "content": [
        {
          "type": "textarea",
          "text": "public class Person {\n    private String name; // private field, accessible only within this class\n \n    public String getName() {\n        return name;\n    }\n \n    public void setName(String newName) {\n        name = newName;\n    }\n}"
        }
      ]
    },
    {
      "title": "Inheritance in Java",
      "description": "Inheritance lets you build a new class (the subclass) on top of an existing one (the superclass), reusing its fields and methods with the extends keyword.",
      "sub_description": "Inheritance promotes code reuse and establishes an is-a relationship between classes.",
      "content": [
        {
          "type": "textarea",
          "text": "class Vehicle {\n    protected String brand = \"Ford\";\n    public void honk() {\n        System.out.println(\"Tuut, tuut!\");\n    }\n}\n \nclass Car extends Vehicle {\n    private String modelName = \"Mustang\";\n \n    public static void main(String[] args) {\n        Car myCar = new Car();\n        myCar.honk();\n        System.out.println(myCar.brand + \" \" + myCar.modelName);\n    }\n}"
        }
      ]
    },
    {
      "title": "Polymorphism in Java",
      "description": "Polymorphism means \"many forms.\" It's what lets a method behave differently depending on which object calls it, usually through overriding in a subclass.",
      "sub_description": "Polymorphism allows one interface to be used for a general class of actions. The specific action is determined by the exact type of object that calls it.",
      "content": [
        {
          "type": "textarea",
          "text": "class Animal {\n    public void animalSound() {\n        System.out.println(\"The animal makes a sound\");\n    }\n}\n \nclass Cat extends Animal {\n    public void animalSound() { // overridden method\n        System.out.println(\"The cat says meow\");\n    }\n}"
        }
      ]
    },
    {
      "title": "Abstraction in Java",
      "description": "Abstraction hides implementation details and shows only what's essential. You get there with abstract classes and interfaces.",
      "sub_description": "Abstraction helps reduce complexity by hiding unnecessary details and exposing only the relevant features of an object.",
      "content": [
        {
          "type": "heading",
          "level": 2,
          "text": "Abstract Classes"
        },
        {
          "type": "textarea",
          "text": "abstract class Animal {\n    public abstract void animalSound(); // no body - must be implemented by subclass\n    public void sleep() {\n        System.out.println(\"Zzz\");\n    }\n}\n \nclass Pig extends Animal {\n    public void animalSound() {\n        System.out.println(\"The pig says wee wee\");\n    }\n}"
        },
        {
          "type": "heading",
          "level": 2,
          "text": "Interfaces"
        },
        {
          "type": "paragraph",
          "text": "An interface is basically a fully \"abstract class\" — a way to group related methods that have no bodies. Any class that wants to use them has to implement the interface with the implements keyword."
        },
        {
          "type": "textarea",
          "text": "interface Animal {\n    public void animalSound(); // interface method (no body)\n}\n \nclass Pig implements Animal {\n    public void animalSound() {\n        System.out.println(\"The pig says wee wee\");\n    }\n}"
        }
      ]
    },
    {
      "title": "Enums in Java",
      "description": "An enum is a special kind of class for representing a fixed set of named constants.",
      "sub_description": "Enums are used when a variable (especially a method parameter) can only take one out of a small set of possible values, making code more readable and less error-prone.",
      "content": [
        {
          "type": "textarea",
          "text": "enum Level {\n    LOW,\n    MEDIUM,\n    HIGH\n}\n \npublic class Main {\n    public static void main(String[] args) {\n        Level myVar = Level.MEDIUM;\n        System.out.println(myVar); // MEDIUM\n    }\n}"
        }
      ]
    }
  ],
  "Exception Handling & Collections": [
    {
      "title": "Exception Handling in Java",
      "description": "Things go wrong while code runs sometimes — bugs, bad input, whatever. Java gives you try, catch, finally, throw, and throws so the program doesn't just crash outright.",
      "sub_description": "Exception handling lets you gracefully recover from runtime errors, keeping your programs robust and user-friendly.",
      "content": [
        {
          "type": "heading",
          "level": 2,
          "text": "Exception Keywords"
        },
        {
          "type": "list",
          "items": [
            "<b>try</b> lets you test a block of code for errors",
            "<b>catch</b> lets you handle whatever error shows up",
            "<b>finally</b> runs no matter what happened in try/catch",
            "<b>throw</b> is for raising a custom exception yourself"
          ]
        },
        {
          "type": "textarea",
          "text": "public class Main {\n    public static void main(String[] args) {\n        try {\n            int[] myNumbers = {1, 2, 3};\n            System.out.println(myNumbers[10]); // out of bounds\n        } catch (Exception e) {\n            System.out.println(\"Something went wrong: \" + e.getMessage());\n        } finally {\n            System.out.println(\"The 'try catch' is finished.\");\n        }\n    }\n}"
        }
      ]
    },
    {
      "title": "Collections in Java (java.util)",
      "description": "The Java Collections Framework hands you ready-made data structures and algorithms, so you don't have to build them from scratch.",
      "sub_description": "Java's Collections Framework provides interfaces and classes for lists, sets, maps, and queues. It is one of the most widely used parts of the Java standard library.",
      "content": [
        {
          "type": "heading",
          "level": 2,
          "text": "ArrayList"
        },
        {
          "type": "paragraph",
          "text": "ArrayList is basically a resizable array. Unlike a plain array, it can grow or shrink after you've created it."
        },
        {
          "type": "textarea",
          "text": "import java.util.ArrayList;\n \npublic class Main {\n    public static void main(String[] args) {\n        ArrayList<String> cars = new ArrayList<String>();\n        cars.add(\"Volvo\");\n        cars.add(\"BMW\");\n        System.out.println(cars.get(0));  // Volvo\n        cars.remove(0);\n        System.out.println(cars.size());  // 1\n    }\n}"
        },
        {
          "type": "heading",
          "level": 2,
          "text": "HashMap"
        },
        {
          "type": "paragraph",
          "text": "A HashMap stores items as key/value pairs — each key mapped to exactly one value."
        },
        {
          "type": "textarea",
          "text": "import java.util.HashMap;\n \npublic class Main {\n    public static void main(String[] args) {\n        HashMap<String, String> capitalCities = new HashMap<String, String>();\n        capitalCities.put(\"England\", \"London\");\n        capitalCities.put(\"India\", \"New Delhi\");\n        System.out.println(capitalCities.get(\"India\")); // New Delhi\n    }\n}"
        },
        {
          "type": "heading",
          "level": 2,
          "text": "Wrapper Classes"
        },
        {
          "type": "paragraph",
          "text": "Wrapper classes let you treat primitive types (int, char, etc.) as objects. Each primitive has a matching wrapper class — Byte, Short, Integer, Long, Float, Double, Character, Boolean — and you'll need them for collections like ArrayList, which only hold objects, not primitives."
        },
        {
          "type": "textarea",
          "text": "Integer myInt = 5;\nDouble myDouble = 5.99;\nCharacter myChar = 'A';"
        }
      ]
    }
  ]
}