[{"data":1,"prerenderedAt":314},["ShallowReactive",2],{"tag-labels":3,"site-header":4,"article-java-method-en":75},{},{"featuredPost":5,"navigations":29},{"id":6,"title":7,"title_id":8,"slug":9,"excerpt":10,"excerpt_id":11,"has_translation":12,"published_at":13,"reading_time":14,"hidden_from_listing":15,"tags":16,"thumbnail_image":21,"og_image":22,"series":23,"authors":28},110,"When You Pick a Framework Just to Look Different","Ketika Pilih Framework Cuma Biar Kelihatan Beda","ketika-pilih-framework-cuma-biar-kelihatan-beda","The last time you chose a new framework or library, was it because your problem needed that tool, or because it sounded cool and few people around you were using it? That question is uncomfortable. Technology decisions are often made for reasons that never appear in any technical document.","Terakhir kali kamu milih framework atau library baru, itu karena masalahmu butuh alat itu, atau karena alatnya kedengaran keren dan belum banyak yang pakai? Pertanyaan ini nggak enak dijawab. Soalnya keputusan teknologi sering diambil dengan alasan yang nggak pernah ditulis di dokumen teknis mana pun.",true,"2026-10-06T15:25:21.000Z",5,false,[17,18,19,20],"karier","framework","opini","pengalaman",null,"\u002Fog\u002Fketika-pilih-framework-cuma-biar-kelihatan-beda.png",{"id":24,"title":25,"title_id":26,"slug":27},9,"Articles","Artikel","all",[],[30,49,70],{"collection":31,"item":32},"series",{"__typename":31,"title":25,"title_id":26,"slug":27,"children_series":33},[34,38,42,46],{"title":35,"title_id":36,"slug":37},"Artificial Intelligence","Kecerdasan Artifisial","kecerdasan-artifisial",{"title":39,"title_id":40,"slug":41},"Programming Fundamentals","Konsep Dasar Pemrograman","konsep-dasar-pemrograman",{"title":43,"title_id":44,"slug":45},"Algorithms and Data Structures","Algoritma dan Struktur Data","algoritma-struktur-data",{"title":47,"title_id":47,"slug":48},"LLM Systems","llm-systems",{"collection":31,"item":50},{"__typename":31,"title":51,"title_id":51,"slug":52,"children_series":53},"Tutorial","tutorial",[54,58,62,66],{"title":55,"title_id":56,"slug":57},"Learning Python","Belajar Python","belajar-python",{"title":59,"title_id":60,"slug":61},"Learning Go","Belajar Golang","belajar-golang",{"title":63,"title_id":64,"slug":65},"Learning Java","Belajar Java","belajar-java",{"title":67,"title_id":68,"slug":69},"Learning Pascal","Belajar Pascal","belajar-pascal",{"collection":31,"item":71},{"__typename":31,"title":72,"title_id":72,"slug":73,"children_series":74},"Lab","lab",[],{"article":76,"renderedBody":179,"renderedTakeaway":180,"latestArticles":181,"toc":291},{"id":77,"title":78,"title_id":79,"slug":80,"excerpt":81,"excerpt_id":82,"has_translation":12,"published_at":83,"reading_time":84,"hidden_from_listing":15,"tags":85,"thumbnail_image":21,"og_image":88,"series":89,"authors":171,"seoTitle":21,"seoDescription":21,"body_locale":174,"available_locales":175,"body":177,"takeway":178,"prerequisite":21},156,"Java Methods: Why applyDiscount Never Changed the Receipt Total","Method di Java: Kenapa applyDiscount Tidak Pernah Mengubah Total Struk","java-method","A receipt prints `subtotal: 25000` on both lines and exits 0. `applyDiscount` assigns to its parameter, which is a copy, so the caller's variable never moves and the total stays 25000 instead of 22500.","Sebuah struk mencetak `subtotal: 25000` di kedua barisnya lalu keluar dengan status 0. `applyDiscount` menugaskan ke parameternya, yang merupakan salinan, jadi variabel pemanggilnya tidak bergerak dan totalnya tetap 25000, bukan 22500.","2026-11-15T01:00:00.000Z",7,[86,87],"java","method","\u002Fog\u002Fjava-method.png",{"id":90,"title":63,"title_id":64,"slug":65,"description":91,"description_id":92,"articles":93,"children_series":149,"parent_series":162},13,"Java is one of the most used languages in the world. It earned that with how it handles large applications and how stable it stays over the years. You'll find it in web apps, mobile apps, and enterprise systems alike. Start here and take it one step at a time.","Java adalah bahasa pemrograman yang sangat populer dan banyak digunakan di seluruh dunia. Dikenal karena kekuatannya dalam pengembangan aplikasi besar dan stabilitasnya, Java dipakai untuk berbagai macam aplikasi seperti aplikasi web, mobile, dan enterprise. Yuk mulai belajar Java bareng Inva!",[94,114,129,144],{"id":95,"title":96,"title_id":97,"slug":98,"excerpt":99,"excerpt_id":100,"has_translation":12,"published_at":101,"reading_time":102,"hidden_from_listing":15,"tags":103,"thumbnail_image":21,"og_image":105,"series":106,"authors":107},149,"Java switch: the 78 That Came Out as a C","Java switch: 78 yang Keluar sebagai C","java-switch","A grading program marks a paper 78 and prints `grade: C`. `case 7` assigns `B` and then runs into `case 6` because the `break` is missing, and the compiler says nothing about it.","Sebuah program penilaian memberi nilai 78 pada satu lembar ujian lalu mencetak `grade: C`. `case 7` memberi `B` lalu jatuh ke `case 6` karena `break`-nya hilang, dan kompilator tidak mengatakan apa pun soal itu.","2026-11-12T01:00:00.000Z",6,[86,104],"percabangan","\u002Fog\u002Fjava-switch.png",{"id":90,"title":63,"title_id":64,"slug":65},[108],{"authors_id":109},{"id":110,"name":111,"slug":112,"role":113,"profile_picture":21},1,"Daffa Izzuddin","izzudd","Writer",{"id":115,"title":116,"title_id":117,"slug":118,"excerpt":119,"excerpt_id":120,"has_translation":12,"published_at":121,"reading_time":102,"hidden_from_listing":15,"tags":122,"thumbnail_image":21,"og_image":124,"series":125,"authors":126},150,"Java Loops: the Last Price That Never Reached the Sum","Loop Java: Harga Terakhir yang Tidak Pernah Masuk ke Total","java-loops","Four prices add up to 47000, and the cart program prints 36500. The bound is `prices.length - 1`, so the last item is never read while the average is still divided by four.","Empat harga berjumlah 47000, tapi program keranjang mencetak 36500. Batasnya `prices.length - 1`, jadi item terakhir tidak pernah dibaca sementara rata-ratanya tetap dibagi empat.","2026-11-13T01:00:00.000Z",[86,123],"loop","\u002Fog\u002Fjava-loops.png",{"id":90,"title":63,"title_id":64,"slug":65},[127],{"authors_id":128},{"id":110,"name":111,"slug":112,"role":113,"profile_picture":21},{"id":130,"title":131,"title_id":132,"slug":133,"excerpt":134,"excerpt_id":135,"has_translation":12,"published_at":136,"reading_time":102,"hidden_from_listing":15,"tags":137,"thumbnail_image":21,"og_image":139,"series":140,"authors":141},154,"Java Arrays: Counting Filled Slots Instead of array.length","Array di Java: Menghitung Slot yang Terisi, Bukan array.length","java-array","Four scores average 79.5 and the register prints 63. `new int[5]` starts every slot at 0, so the empty desk enters the sum as a student who scored nothing, and the division still uses the slot count.","Empat nilai rata-ratanya 79.5, tapi daftar itu mencetak 63. `new int[5]` memulai setiap slot dari 0, jadi meja kosong ikut masuk ke jumlah sebagai siswa yang tidak dapat nilai, dan pembagiannya tetap memakai jumlah slot.","2026-11-14T01:00:00.000Z",[86,138],"array","\u002Fog\u002Fjava-array.png",{"id":90,"title":63,"title_id":64,"slug":65},[142],{"authors_id":143},{"id":110,"name":111,"slug":112,"role":113,"profile_picture":21},{"id":77,"title":78,"title_id":79,"slug":80,"excerpt":81,"excerpt_id":82,"has_translation":12,"published_at":83,"reading_time":84,"hidden_from_listing":15,"tags":85,"thumbnail_image":21,"og_image":88,"series":145,"authors":146},{"id":90,"title":63,"title_id":64,"slug":65},[147],{"authors_id":148},{"id":110,"name":111,"slug":112,"role":113,"profile_picture":21},[150,156],{"id":151,"title":152,"title_id":153,"slug":154,"description":155,"cover_image":21},21,"Getting Started with Java","Berkenalan dengan Java","java-intro","Meet Java from scratch: your first program, how the pieces fit together, and how to read input and print output.",{"id":157,"title":158,"title_id":159,"slug":160,"description":161,"cover_image":21},22,"Variables, Types, and Operations","Variabel, Tipe Data, dan Operasi","java-variabel-tipe-data","In Java the type has to be clear from the start. We go through the primitive types, then integers and floats in more depth.",{"id":110,"title":51,"title_id":51,"slug":52,"parent_series":21,"children_series":163},[164,166,168,169],{"id":165,"title":55,"title_id":56,"slug":57,"cover_image":21},10,{"id":167,"title":59,"title_id":60,"slug":61,"cover_image":21},11,{"id":90,"title":63,"title_id":64,"slug":65,"cover_image":21},{"id":170,"title":67,"title_id":68,"slug":69,"cover_image":21},14,[172],{"authors_id":173},{"id":110,"name":111,"slug":112,"role":113,"profile_picture":21},"en",[174,176],"id","\nYour receipt prints the subtotal twice, the discount never shows up, and the program exits 0 with no error. The method modified its local copy of the parameter, leaving the caller's variable unchanged.\n\n## The method that subtracts nothing\n\nHere is the broken program. `applyDiscount` takes a price, subtracts 2500 from it, and returns nothing. `main` calls it with a subtotal of 25000, then prints that subtotal under two labels. Every run in this article used Temurin JDK 21.0.13 on Linux.\n\n```java\n\u002F\u002F Receipt.java\npublic class Receipt {\n    static void applyDiscount(int total) {\n        total = total - 2500;\n    }\n\n    public static void main(String[] args) {\n        int subtotal = 25000;\n        applyDiscount(subtotal);\n        System.out.println(\"subtotal: \" + subtotal);\n        System.out.println(\"total: \" + subtotal);\n    }\n}\n```\n\n```plain\n$ javac Receipt.java && java Receipt\nsubtotal: 25000\ntotal: 25000\n```\n\nBoth lines say 25000. The discount is 2500, so the total should be 22500. The compiler accepts the code and the program exits 0, so nothing flags the mistake.\n\n## Why the caller's price never changes\n\nRead the call `applyDiscount(subtotal)` one clause at a time.\n\n1. Java reads the variable `subtotal` and gets the value 25000.\n2. It copies that value into the parameter `total`, a new variable that belongs to the method.\n3. The line `total = total - 2500` stores 22500 in that new variable.\n4. The method is `void`, so it returns nothing. The 22500 is neither printed nor assigned inside the method, so it is gone when the method ends.\n5. Back in `main`, `subtotal` was never touched. It still holds 25000.\n\nThis is pass-by-value. Java passes every argument by value, so the parameter is a copy of the caller's variable. The [Oracle tutorial on passing arguments](https:\u002F\u002Fdocs.oracle.com\u002Fjavase\u002Ftutorial\u002Fjava\u002FjavaOO\u002Farguments.html) covers it. The language specification defines method declarations in section 8.4.1.\n\n## A check you can run\n\nReading two lines by eye works. A checker works for any number of lines. `CheckReceipt` reads standard input and compares each line to the text it expects. It prints PASS or FAIL for each line and exits with status 1 if any check fails.\n\n```java\n\u002F\u002F CheckReceipt.java\nimport java.util.List;\nimport java.util.Scanner;\n\npublic class CheckReceipt {\n    public static void main(String[] args) {\n        List\u003CString> expected = List.of(\"subtotal: 25000\", \"total: 22500\");\n        Scanner in = new Scanner(System.in);\n        int passed = 0;\n        for (int i = 0; i \u003C expected.size(); i++) {\n            String got = in.hasNextLine() ? in.nextLine() : \"\u003Cnothing>\";\n            if (got.equals(expected.get(i))) {\n                passed++;\n                System.out.println(\"PASS  line \" + (i + 1) + \": \" + got);\n            } else {\n                System.out.println(\"FAIL  line \" + (i + 1) + \": expected \" + expected.get(i) + \", got \" + got);\n            }\n        }\n        if (in.hasNextLine()) {\n            System.out.println(\"FAIL  extra line: \" + in.nextLine());\n        }\n        System.out.println();\n        System.out.println(passed + \" of \" + expected.size() + \" checks passed\");\n        if (passed != expected.size()) {\n            System.exit(1);\n        }\n    }\n}\n```\n\nThe `|` sends the output of `Receipt` into the input of `CheckReceipt`.\n\n```plain\n$ javac CheckReceipt.java && java Receipt | java CheckReceipt\nPASS  line 1: subtotal: 25000\nFAIL  line 2: expected total: 22500, got total: 25000\n\n1 of 2 checks passed\n```\n\nLine 1 passes. Line 2 fails with the same wrong number you saw by eye, and the checker exits with status 1. The red run gives you a target: make line 2 say 22500.\n\n## Return the number and assign it\n\nHand the answer back. The return type becomes `int`, the body becomes `return total - 2500;`, and `main` assigns the result to a new variable named `total`.\n\n```java\n\u002F\u002F Receipt.java\npublic class Receipt {\n    static int applyDiscount(int total) {\n        return total - 2500;\n    }\n\n    public static void main(String[] args) {\n        int subtotal = 25000;\n        int total = applyDiscount(subtotal);\n        System.out.println(\"subtotal: \" + subtotal);\n        System.out.println(\"total: \" + total);\n    }\n}\n```\n\n```plain\n$ javac Receipt.java && java Receipt\nsubtotal: 25000\ntotal: 22500\n```\n\n```plain\n$ java Receipt | java CheckReceipt\nPASS  line 1: subtotal: 25000\nPASS  line 2: total: 22500\n\n2 of 2 checks passed\n```\n\nThe checker is green and exits with status 0. `subtotal` still holds 25000 because `applyDiscount` never modified it, and `main` now assigns the returned value to `total`.\n\nA returned number can still be wrong in a quieter way. `Average.java` divides 47000 by 3 and prints `15666.0`, not `15666.666666666666`.\n\n```java\n\u002F\u002F Average.java\npublic class Average {\n    static double average(int sum, int count) {\n        return sum \u002F count;\n    }\n\n    public static void main(String[] args) {\n        System.out.println(\"average: \" + average(47000, 3));\n    }\n}\n```\n\n```plain\n$ javac Average.java && java Average\naverage: 15666.0\n```\n\nBoth `sum` and `count` are `int`, so `sum \u002F count` is integer division. The fraction is dropped first. The `double` return type then widens the already-truncated 15666.\n\n## The array that does change\n\nArrays look like a contradiction. `applyDiscount` below changes the caller's data, and `reset` does not.\n\n```java\n\u002F\u002F Cart.java\npublic class Cart {\n    static void applyDiscount(int[] prices) {\n        for (int i = 0; i \u003C prices.length; i++) {\n            prices[i] = prices[i] - 2500;\n        }\n    }\n\n    static void reset(int[] prices) {\n        prices = new int[] {0, 0};\n    }\n\n    public static void main(String[] args) {\n        int[] prices = {25000, 40000};\n        applyDiscount(prices);\n        System.out.println(\"after applyDiscount: \" + prices[0] + \" \" + prices[1]);\n        reset(prices);\n        System.out.println(\"after reset: \" + prices[0] + \" \" + prices[1]);\n    }\n}\n```\n\n```plain\n$ javac Cart.java && java Cart\nafter applyDiscount: 22500 37500\nafter reset: 22500 37500\n```\n\nThe first line, 22500 37500, is not a counterexample. An array argument is also a copy, but the copy is a reference to the same array. Writing `prices[i]` follows that reference and changes the caller's elements.\n\nThe second line shows the copy is still a copy. In `reset`, the assignment gives the parameter a new array and moves only the copy. The caller's `prices` still points at the old array, so it prints 22500 37500 again.\n\n## Two methods with one name\n\nA class can hold two methods with the same name if their parameter types differ. The compiler chooses between them from the declared types of the arguments, before the program runs.\n\n```java\n\u002F\u002F Overload.java\npublic class Overload {\n    static void label(int total) {\n        System.out.println(\"int overload\");\n    }\n\n    static void label(double total) {\n        System.out.println(\"double overload\");\n    }\n\n    public static void main(String[] args) {\n        label(25000);\n        label(25000.0);\n        label('A');\n        short s = 250;\n        label(s);\n    }\n}\n```\n\n```plain\n$ javac Overload.java && java Overload\nint overload\ndouble overload\nint overload\nint overload\n```\n\nThe literal `25000` is an `int`, and `25000.0` is a `double`. A `char` and a `short` both widen to `int`, so `'A'` and the `short` holding 250 pick the `int` overload. The [language specification](https:\u002F\u002Fdocs.oracle.com\u002Fjavase\u002Fspecs\u002Fjls\u002Fse21\u002Fhtml\u002Fjls-15.html) describes the full rules in section 15.12.2.\n\n## Before the next article\n\nIn the fixed `Receipt.java`, change `int subtotal = 25000;` to `int subtotal = 40000;`. Recompile it, run it, and pipe it into the same checker. The receipt prints `subtotal: 40000` and `total: 37500`. The checker reports `0 of 2 checks passed` and exits with status 1, because its two expected lines are fixed at 25000 and 22500.\n\nBoth receipt lines are correct for a 40000 subtotal; the checker fails only because its expected output is hardcoded to 25000 and 22500.\n","- Java passes every argument by value, so a method that assigns to its parameter changes a copy and leaves the caller's variable alone.\n- A `void` method returns nothing, so a value computed inside it is gone unless the method prints or stores it before it ends.\n- The fixed version returns `int` and the caller assigns the result, which is what puts `total: 22500` on the receipt.\n- An array argument is a copy of a reference, so `prices[i] = ...` changes the caller's elements while `prices = new int[] {0, 0}` moves only the copy.\n- A `double` return type does not rescue integer division: `sum \u002F count` on two `int`s drops the fraction before the widening.\n- Overloads are chosen at compile time from the declared argument types, so `char` and `short` both widen to `int` and pick the `int` overload.","\u003Cp>Your receipt prints the subtotal twice, the discount never shows up, and the program exits 0 with no error. The method modified its local copy of the parameter, leaving the caller&#39;s variable unchanged.\u003C\u002Fp>\n\u003Ch2 id=\"the-method-that-subtracts-nothing\">The method that subtracts nothing\u003C\u002Fh2>\n\u003Cp>Here is the broken program. \u003Ccode>applyDiscount\u003C\u002Fcode> takes a price, subtracts 2500 from it, and returns nothing. \u003Ccode>main\u003C\u002Fcode> calls it with a subtotal of 25000, then prints that subtotal under two labels. Every run in this article used Temurin JDK 21.0.13 on Linux.\u003C\u002Fp>\n\n\u003Cdiv class=\"code-block-wrapper my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden bg-[#24292e] text-[#e1e4e8] transition-all\">\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ff5f56] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ffbd2e] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#27c93f] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"ml-2 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">JAVA\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"%2F%2F%20Receipt.java%0Apublic%20class%20Receipt%20%7B%0A%20%20%20%20static%20void%20applyDiscount(int%20total)%20%7B%0A%20%20%20%20%20%20%20%20total%20%3D%20total%20-%202500%3B%0A%20%20%20%20%7D%0A%0A%20%20%20%20public%20static%20void%20main(String%5B%5D%20args)%20%7B%0A%20%20%20%20%20%20%20%20int%20subtotal%20%3D%2025000%3B%0A%20%20%20%20%20%20%20%20applyDiscount(subtotal)%3B%0A%20%20%20%20%20%20%20%20System.out.println(%22subtotal%3A%20%22%20%2B%20subtotal)%3B%0A%20%20%20%20%20%20%20%20System.out.println(%22total%3A%20%22%20%2B%20subtotal)%3B%0A%20%20%20%20%7D%0A%7D\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed bg-[#24292e]\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"color:#6A737D\">\u002F\u002F Receipt.java\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">public\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> class\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\"> Receipt\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">    static\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> void\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\"> applyDiscount\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">int\u003C\u002Fspan>\u003Cspan style=\"color:#FFAB70\"> total\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">) {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        total \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> total \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">-\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\"> 2500\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">;\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">    }\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">    public\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> static\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> void\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\"> main\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">String\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">[] \u003C\u002Fspan>\u003Cspan style=\"color:#FFAB70\">args\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">) {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">        int\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> subtotal \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\"> 25000\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">;\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#B392F0\">        applyDiscount\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(subtotal);\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        System.out.\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">println\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"subtotal: \"\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> +\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> subtotal);\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        System.out.\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">println\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"total: \"\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> +\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> subtotal);\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">    }\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">}\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\u003Cdiv class=\"code-block-wrapper code-output my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden text-[#e1e4e8] transition-all\" data-output-block>\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"code-output-mark\" aria-hidden=\"true\">&gt;_\u003C\u002Fspan>\n      \u003Cspan class=\"ml-1 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">Output\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"%24%20javac%20Receipt.java%20%26%26%20java%20Receipt%0Asubtotal%3A%2025000%0Atotal%3A%2025000\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\">\u003Ccode>\u003Cspan class=\"code-output-cmd\">$ javac Receipt.java &amp;&amp; java Receipt\u003C\u002Fspan>\nsubtotal: 25000\ntotal: 25000\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\u003Cp>Both lines say 25000. The discount is 2500, so the total should be 22500. The compiler accepts the code and the program exits 0, so nothing flags the mistake.\u003C\u002Fp>\n\u003Ch2 id=\"why-the-caller-s-price-never-changes\">Why the caller&#39;s price never changes\u003C\u002Fh2>\n\u003Cp>Read the call \u003Ccode>applyDiscount(subtotal)\u003C\u002Fcode> one clause at a time.\u003C\u002Fp>\n\u003Col>\n\u003Cli>Java reads the variable \u003Ccode>subtotal\u003C\u002Fcode> and gets the value 25000.\u003C\u002Fli>\n\u003Cli>It copies that value into the parameter \u003Ccode>total\u003C\u002Fcode>, a new variable that belongs to the method.\u003C\u002Fli>\n\u003Cli>The line \u003Ccode>total = total - 2500\u003C\u002Fcode> stores 22500 in that new variable.\u003C\u002Fli>\n\u003Cli>The method is \u003Ccode>void\u003C\u002Fcode>, so it returns nothing. The 22500 is neither printed nor assigned inside the method, so it is gone when the method ends.\u003C\u002Fli>\n\u003Cli>Back in \u003Ccode>main\u003C\u002Fcode>, \u003Ccode>subtotal\u003C\u002Fcode> was never touched. It still holds 25000.\u003C\u002Fli>\n\u003C\u002Fol>\n\u003Cp>This is pass-by-value. Java passes every argument by value, so the parameter is a copy of the caller&#39;s variable. The \u003Ca href=\"https:\u002F\u002Fdocs.oracle.com\u002Fjavase\u002Ftutorial\u002Fjava\u002FjavaOO\u002Farguments.html\">Oracle tutorial on passing arguments\u003C\u002Fa> covers it. The language specification defines method declarations in section 8.4.1.\u003C\u002Fp>\n\u003Ch2 id=\"a-check-you-can-run\">A check you can run\u003C\u002Fh2>\n\u003Cp>Reading two lines by eye works. A checker works for any number of lines. \u003Ccode>CheckReceipt\u003C\u002Fcode> reads standard input and compares each line to the text it expects. It prints PASS or FAIL for each line and exits with status 1 if any check fails.\u003C\u002Fp>\n\n\u003Cdiv class=\"code-block-wrapper my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden bg-[#24292e] text-[#e1e4e8] transition-all\">\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ff5f56] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ffbd2e] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#27c93f] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"ml-2 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">JAVA\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"%2F%2F%20CheckReceipt.java%0Aimport%20java.util.List%3B%0Aimport%20java.util.Scanner%3B%0A%0Apublic%20class%20CheckReceipt%20%7B%0A%20%20%20%20public%20static%20void%20main(String%5B%5D%20args)%20%7B%0A%20%20%20%20%20%20%20%20List%3CString%3E%20expected%20%3D%20List.of(%22subtotal%3A%2025000%22%2C%20%22total%3A%2022500%22)%3B%0A%20%20%20%20%20%20%20%20Scanner%20in%20%3D%20new%20Scanner(System.in)%3B%0A%20%20%20%20%20%20%20%20int%20passed%20%3D%200%3B%0A%20%20%20%20%20%20%20%20for%20(int%20i%20%3D%200%3B%20i%20%3C%20expected.size()%3B%20i%2B%2B)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20String%20got%20%3D%20in.hasNextLine()%20%3F%20in.nextLine()%20%3A%20%22%3Cnothing%3E%22%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20(got.equals(expected.get(i)))%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20passed%2B%2B%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20System.out.println(%22PASS%20%20line%20%22%20%2B%20(i%20%2B%201)%20%2B%20%22%3A%20%22%20%2B%20got)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20System.out.println(%22FAIL%20%20line%20%22%20%2B%20(i%20%2B%201)%20%2B%20%22%3A%20expected%20%22%20%2B%20expected.get(i)%20%2B%20%22%2C%20got%20%22%20%2B%20got)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20if%20(in.hasNextLine())%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20System.out.println(%22FAIL%20%20extra%20line%3A%20%22%20%2B%20in.nextLine())%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20System.out.println()%3B%0A%20%20%20%20%20%20%20%20System.out.println(passed%20%2B%20%22%20of%20%22%20%2B%20expected.size()%20%2B%20%22%20checks%20passed%22)%3B%0A%20%20%20%20%20%20%20%20if%20(passed%20!%3D%20expected.size())%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20System.exit(1)%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%7D\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed bg-[#24292e]\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"color:#6A737D\">\u002F\u002F CheckReceipt.java\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">import\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> java.util.List;\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">import\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> java.util.Scanner;\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">public\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> class\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\"> CheckReceipt\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">    public\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> static\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> void\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\"> main\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">String\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">[] \u003C\u002Fspan>\u003Cspan style=\"color:#FFAB70\">args\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">) {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        List&#x3C;\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">String\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">> expected \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> List.\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">of\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"subtotal: 25000\"\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">, \u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"total: 22500\"\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">);\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        Scanner in \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> new\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\"> Scanner\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(System.in);\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">        int\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> passed \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\"> 0\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">;\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">        for\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> (\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">int\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> i \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\"> 0\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">; i \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">&#x3C;\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> expected.\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">size\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(); i\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">++\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">) {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">            String got \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> in.\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">hasNextLine\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">() \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">?\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> in.\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">nextLine\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">() \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">:\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\"> \"&#x3C;nothing>\"\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">;\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">            if\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> (got.\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">equals\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(expected.\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">get\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(i))) {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">                passed\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">++\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">;\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">                System.out.\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">println\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"PASS  line \"\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> +\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> (i \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">+\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\"> 1\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">) \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">+\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\"> \": \"\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> +\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> got);\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">            } \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">else\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">                System.out.\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">println\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"FAIL  line \"\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> +\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> (i \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">+\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\"> 1\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">) \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">+\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\"> \": expected \"\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> +\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> expected.\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">get\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(i) \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">+\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\"> \", got \"\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> +\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> got);\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">            }\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        }\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">        if\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> (in.\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">hasNextLine\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">()) {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">            System.out.\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">println\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"FAIL  extra line: \"\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> +\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> in.\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">nextLine\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">());\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        }\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        System.out.\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">println\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">();\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        System.out.\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">println\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(passed \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">+\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\"> \" of \"\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> +\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> expected.\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">size\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">() \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">+\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\"> \" checks passed\"\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">);\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">        if\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> (passed \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">!=\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> expected.\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">size\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">()) {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">            System.\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">exit\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">1\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">);\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        }\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">    }\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">}\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\u003Cp>The \u003Ccode>|\u003C\u002Fcode> sends the output of \u003Ccode>Receipt\u003C\u002Fcode> into the input of \u003Ccode>CheckReceipt\u003C\u002Fcode>.\u003C\u002Fp>\n\n\u003Cdiv class=\"code-block-wrapper code-output my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden text-[#e1e4e8] transition-all\" data-output-block>\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"code-output-mark\" aria-hidden=\"true\">&gt;_\u003C\u002Fspan>\n      \u003Cspan class=\"ml-1 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">Output\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"%24%20javac%20CheckReceipt.java%20%26%26%20java%20Receipt%20%7C%20java%20CheckReceipt%0APASS%20%20line%201%3A%20subtotal%3A%2025000%0AFAIL%20%20line%202%3A%20expected%20total%3A%2022500%2C%20got%20total%3A%2025000%0A%0A1%20of%202%20checks%20passed\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\">\u003Ccode>\u003Cspan class=\"code-output-cmd\">$ javac CheckReceipt.java &amp;&amp; java Receipt | java CheckReceipt\u003C\u002Fspan>\nPASS  line 1: subtotal: 25000\nFAIL  line 2: expected total: 22500, got total: 25000\n\n1 of 2 checks passed\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\u003Cp>Line 1 passes. Line 2 fails with the same wrong number you saw by eye, and the checker exits with status 1. The red run gives you a target: make line 2 say 22500.\u003C\u002Fp>\n\u003Ch2 id=\"return-the-number-and-assign-it\">Return the number and assign it\u003C\u002Fh2>\n\u003Cp>Hand the answer back. The return type becomes \u003Ccode>int\u003C\u002Fcode>, the body becomes \u003Ccode>return total - 2500;\u003C\u002Fcode>, and \u003Ccode>main\u003C\u002Fcode> assigns the result to a new variable named \u003Ccode>total\u003C\u002Fcode>.\u003C\u002Fp>\n\n\u003Cdiv class=\"code-block-wrapper my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden bg-[#24292e] text-[#e1e4e8] transition-all\">\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ff5f56] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ffbd2e] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#27c93f] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"ml-2 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">JAVA\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"%2F%2F%20Receipt.java%0Apublic%20class%20Receipt%20%7B%0A%20%20%20%20static%20int%20applyDiscount(int%20total)%20%7B%0A%20%20%20%20%20%20%20%20return%20total%20-%202500%3B%0A%20%20%20%20%7D%0A%0A%20%20%20%20public%20static%20void%20main(String%5B%5D%20args)%20%7B%0A%20%20%20%20%20%20%20%20int%20subtotal%20%3D%2025000%3B%0A%20%20%20%20%20%20%20%20int%20total%20%3D%20applyDiscount(subtotal)%3B%0A%20%20%20%20%20%20%20%20System.out.println(%22subtotal%3A%20%22%20%2B%20subtotal)%3B%0A%20%20%20%20%20%20%20%20System.out.println(%22total%3A%20%22%20%2B%20total)%3B%0A%20%20%20%20%7D%0A%7D\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed bg-[#24292e]\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"color:#6A737D\">\u002F\u002F Receipt.java\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">public\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> class\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\"> Receipt\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">    static\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> int\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\"> applyDiscount\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">int\u003C\u002Fspan>\u003Cspan style=\"color:#FFAB70\"> total\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">) {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">        return\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> total \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">-\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\"> 2500\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">;\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">    }\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">    public\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> static\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> void\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\"> main\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">String\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">[] \u003C\u002Fspan>\u003Cspan style=\"color:#FFAB70\">args\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">) {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">        int\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> subtotal \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\"> 25000\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">;\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">        int\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> total \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\"> applyDiscount\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(subtotal);\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        System.out.\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">println\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"subtotal: \"\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> +\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> subtotal);\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        System.out.\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">println\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"total: \"\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> +\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> total);\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">    }\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">}\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\u003Cdiv class=\"code-block-wrapper code-output my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden text-[#e1e4e8] transition-all\" data-output-block>\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"code-output-mark\" aria-hidden=\"true\">&gt;_\u003C\u002Fspan>\n      \u003Cspan class=\"ml-1 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">Output\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"%24%20javac%20Receipt.java%20%26%26%20java%20Receipt%0Asubtotal%3A%2025000%0Atotal%3A%2022500\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\">\u003Ccode>\u003Cspan class=\"code-output-cmd\">$ javac Receipt.java &amp;&amp; java Receipt\u003C\u002Fspan>\nsubtotal: 25000\ntotal: 22500\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\u003Cdiv class=\"code-block-wrapper code-output my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden text-[#e1e4e8] transition-all\" data-output-block>\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"code-output-mark\" aria-hidden=\"true\">&gt;_\u003C\u002Fspan>\n      \u003Cspan class=\"ml-1 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">Output\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"%24%20java%20Receipt%20%7C%20java%20CheckReceipt%0APASS%20%20line%201%3A%20subtotal%3A%2025000%0APASS%20%20line%202%3A%20total%3A%2022500%0A%0A2%20of%202%20checks%20passed\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\">\u003Ccode>\u003Cspan class=\"code-output-cmd\">$ java Receipt | java CheckReceipt\u003C\u002Fspan>\nPASS  line 1: subtotal: 25000\nPASS  line 2: total: 22500\n\n2 of 2 checks passed\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\u003Cp>The checker is green and exits with status 0. \u003Ccode>subtotal\u003C\u002Fcode> still holds 25000 because \u003Ccode>applyDiscount\u003C\u002Fcode> never modified it, and \u003Ccode>main\u003C\u002Fcode> now assigns the returned value to \u003Ccode>total\u003C\u002Fcode>.\u003C\u002Fp>\n\u003Cp>A returned number can still be wrong in a quieter way. \u003Ccode>Average.java\u003C\u002Fcode> divides 47000 by 3 and prints \u003Ccode>15666.0\u003C\u002Fcode>, not \u003Ccode>15666.666666666666\u003C\u002Fcode>.\u003C\u002Fp>\n\n\u003Cdiv class=\"code-block-wrapper my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden bg-[#24292e] text-[#e1e4e8] transition-all\">\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ff5f56] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ffbd2e] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#27c93f] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"ml-2 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">JAVA\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"%2F%2F%20Average.java%0Apublic%20class%20Average%20%7B%0A%20%20%20%20static%20double%20average(int%20sum%2C%20int%20count)%20%7B%0A%20%20%20%20%20%20%20%20return%20sum%20%2F%20count%3B%0A%20%20%20%20%7D%0A%0A%20%20%20%20public%20static%20void%20main(String%5B%5D%20args)%20%7B%0A%20%20%20%20%20%20%20%20System.out.println(%22average%3A%20%22%20%2B%20average(47000%2C%203))%3B%0A%20%20%20%20%7D%0A%7D\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed bg-[#24292e]\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"color:#6A737D\">\u002F\u002F Average.java\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">public\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> class\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\"> Average\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">    static\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> double\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\"> average\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">int\u003C\u002Fspan>\u003Cspan style=\"color:#FFAB70\"> sum\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">, \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">int\u003C\u002Fspan>\u003Cspan style=\"color:#FFAB70\"> count\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">) {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">        return\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> sum \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">\u002F\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> count;\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">    }\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">    public\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> static\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> void\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\"> main\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">String\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">[] \u003C\u002Fspan>\u003Cspan style=\"color:#FFAB70\">args\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">) {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        System.out.\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">println\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"average: \"\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> +\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\"> average\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">47000\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">, \u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">3\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">));\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">    }\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">}\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\u003Cdiv class=\"code-block-wrapper code-output my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden text-[#e1e4e8] transition-all\" data-output-block>\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"code-output-mark\" aria-hidden=\"true\">&gt;_\u003C\u002Fspan>\n      \u003Cspan class=\"ml-1 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">Output\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"%24%20javac%20Average.java%20%26%26%20java%20Average%0Aaverage%3A%2015666.0\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\">\u003Ccode>\u003Cspan class=\"code-output-cmd\">$ javac Average.java &amp;&amp; java Average\u003C\u002Fspan>\naverage: 15666.0\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\u003Cp>Both \u003Ccode>sum\u003C\u002Fcode> and \u003Ccode>count\u003C\u002Fcode> are \u003Ccode>int\u003C\u002Fcode>, so \u003Ccode>sum \u002F count\u003C\u002Fcode> is integer division. The fraction is dropped first. The \u003Ccode>double\u003C\u002Fcode> return type then widens the already-truncated 15666.\u003C\u002Fp>\n\u003Ch2 id=\"the-array-that-does-change\">The array that does change\u003C\u002Fh2>\n\u003Cp>Arrays look like a contradiction. \u003Ccode>applyDiscount\u003C\u002Fcode> below changes the caller&#39;s data, and \u003Ccode>reset\u003C\u002Fcode> does not.\u003C\u002Fp>\n\n\u003Cdiv class=\"code-block-wrapper my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden bg-[#24292e] text-[#e1e4e8] transition-all\">\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ff5f56] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ffbd2e] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#27c93f] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"ml-2 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">JAVA\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"%2F%2F%20Cart.java%0Apublic%20class%20Cart%20%7B%0A%20%20%20%20static%20void%20applyDiscount(int%5B%5D%20prices)%20%7B%0A%20%20%20%20%20%20%20%20for%20(int%20i%20%3D%200%3B%20i%20%3C%20prices.length%3B%20i%2B%2B)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20prices%5Bi%5D%20%3D%20prices%5Bi%5D%20-%202500%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%0A%20%20%20%20static%20void%20reset(int%5B%5D%20prices)%20%7B%0A%20%20%20%20%20%20%20%20prices%20%3D%20new%20int%5B%5D%20%7B0%2C%200%7D%3B%0A%20%20%20%20%7D%0A%0A%20%20%20%20public%20static%20void%20main(String%5B%5D%20args)%20%7B%0A%20%20%20%20%20%20%20%20int%5B%5D%20prices%20%3D%20%7B25000%2C%2040000%7D%3B%0A%20%20%20%20%20%20%20%20applyDiscount(prices)%3B%0A%20%20%20%20%20%20%20%20System.out.println(%22after%20applyDiscount%3A%20%22%20%2B%20prices%5B0%5D%20%2B%20%22%20%22%20%2B%20prices%5B1%5D)%3B%0A%20%20%20%20%20%20%20%20reset(prices)%3B%0A%20%20%20%20%20%20%20%20System.out.println(%22after%20reset%3A%20%22%20%2B%20prices%5B0%5D%20%2B%20%22%20%22%20%2B%20prices%5B1%5D)%3B%0A%20%20%20%20%7D%0A%7D\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed bg-[#24292e]\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"color:#6A737D\">\u002F\u002F Cart.java\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">public\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> class\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\"> Cart\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">    static\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> void\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\"> applyDiscount\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">int\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">[] \u003C\u002Fspan>\u003Cspan style=\"color:#FFAB70\">prices\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">) {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">        for\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> (\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">int\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> i \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\"> 0\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">; i \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">&#x3C;\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> prices.length; i\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">++\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">) {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">            prices[i] \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> prices[i] \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">-\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\"> 2500\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">;\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        }\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">    }\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">    static\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> void\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\"> reset\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">int\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">[] \u003C\u002Fspan>\u003Cspan style=\"color:#FFAB70\">prices\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">) {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        prices \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> new\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> int\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">[] {\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">0\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">, \u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">0\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">};\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">    }\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">    public\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> static\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> void\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\"> main\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">String\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">[] \u003C\u002Fspan>\u003Cspan style=\"color:#FFAB70\">args\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">) {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">        int\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">[] prices \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> {\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">25000\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">, \u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">40000\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">};\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#B392F0\">        applyDiscount\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(prices);\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        System.out.\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">println\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"after applyDiscount: \"\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> +\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> prices[\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">0\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">] \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">+\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\"> \" \"\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> +\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> prices[\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">1\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">]);\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#B392F0\">        reset\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(prices);\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        System.out.\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">println\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"after reset: \"\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> +\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> prices[\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">0\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">] \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">+\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\"> \" \"\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> +\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> prices[\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">1\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">]);\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">    }\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">}\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\u003Cdiv class=\"code-block-wrapper code-output my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden text-[#e1e4e8] transition-all\" data-output-block>\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"code-output-mark\" aria-hidden=\"true\">&gt;_\u003C\u002Fspan>\n      \u003Cspan class=\"ml-1 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">Output\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"%24%20javac%20Cart.java%20%26%26%20java%20Cart%0Aafter%20applyDiscount%3A%2022500%2037500%0Aafter%20reset%3A%2022500%2037500\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\">\u003Ccode>\u003Cspan class=\"code-output-cmd\">$ javac Cart.java &amp;&amp; java Cart\u003C\u002Fspan>\nafter applyDiscount: 22500 37500\nafter reset: 22500 37500\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\u003Cp>The first line, 22500 37500, is not a counterexample. An array argument is also a copy, but the copy is a reference to the same array. Writing \u003Ccode>prices[i]\u003C\u002Fcode> follows that reference and changes the caller&#39;s elements.\u003C\u002Fp>\n\u003Cp>The second line shows the copy is still a copy. In \u003Ccode>reset\u003C\u002Fcode>, the assignment gives the parameter a new array and moves only the copy. The caller&#39;s \u003Ccode>prices\u003C\u002Fcode> still points at the old array, so it prints 22500 37500 again.\u003C\u002Fp>\n\u003Ch2 id=\"two-methods-with-one-name\">Two methods with one name\u003C\u002Fh2>\n\u003Cp>A class can hold two methods with the same name if their parameter types differ. The compiler chooses between them from the declared types of the arguments, before the program runs.\u003C\u002Fp>\n\n\u003Cdiv class=\"code-block-wrapper my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden bg-[#24292e] text-[#e1e4e8] transition-all\">\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ff5f56] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ffbd2e] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#27c93f] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"ml-2 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">JAVA\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"%2F%2F%20Overload.java%0Apublic%20class%20Overload%20%7B%0A%20%20%20%20static%20void%20label(int%20total)%20%7B%0A%20%20%20%20%20%20%20%20System.out.println(%22int%20overload%22)%3B%0A%20%20%20%20%7D%0A%0A%20%20%20%20static%20void%20label(double%20total)%20%7B%0A%20%20%20%20%20%20%20%20System.out.println(%22double%20overload%22)%3B%0A%20%20%20%20%7D%0A%0A%20%20%20%20public%20static%20void%20main(String%5B%5D%20args)%20%7B%0A%20%20%20%20%20%20%20%20label(25000)%3B%0A%20%20%20%20%20%20%20%20label(25000.0)%3B%0A%20%20%20%20%20%20%20%20label('A')%3B%0A%20%20%20%20%20%20%20%20short%20s%20%3D%20250%3B%0A%20%20%20%20%20%20%20%20label(s)%3B%0A%20%20%20%20%7D%0A%7D\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed bg-[#24292e]\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"color:#6A737D\">\u002F\u002F Overload.java\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">public\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> class\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\"> Overload\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">    static\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> void\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\"> label\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">int\u003C\u002Fspan>\u003Cspan style=\"color:#FFAB70\"> total\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">) {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        System.out.\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">println\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"int overload\"\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">);\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">    }\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">    static\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> void\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\"> label\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">double\u003C\u002Fspan>\u003Cspan style=\"color:#FFAB70\"> total\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">) {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        System.out.\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">println\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"double overload\"\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">);\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">    }\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">    public\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> static\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> void\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\"> main\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">String\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">[] \u003C\u002Fspan>\u003Cspan style=\"color:#FFAB70\">args\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">) {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#B392F0\">        label\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">25000\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">);\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#B392F0\">        label\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">25000.0\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">);\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#B392F0\">        label\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">'A'\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">);\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">        short\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> s \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\"> 250\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">;\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#B392F0\">        label\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(s);\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">    }\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">}\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\u003Cdiv class=\"code-block-wrapper code-output my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden text-[#e1e4e8] transition-all\" data-output-block>\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"code-output-mark\" aria-hidden=\"true\">&gt;_\u003C\u002Fspan>\n      \u003Cspan class=\"ml-1 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">Output\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"%24%20javac%20Overload.java%20%26%26%20java%20Overload%0Aint%20overload%0Adouble%20overload%0Aint%20overload%0Aint%20overload\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\">\u003Ccode>\u003Cspan class=\"code-output-cmd\">$ javac Overload.java &amp;&amp; java Overload\u003C\u002Fspan>\nint overload\ndouble overload\nint overload\nint overload\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\u003Cp>The literal \u003Ccode>25000\u003C\u002Fcode> is an \u003Ccode>int\u003C\u002Fcode>, and \u003Ccode>25000.0\u003C\u002Fcode> is a \u003Ccode>double\u003C\u002Fcode>. A \u003Ccode>char\u003C\u002Fcode> and a \u003Ccode>short\u003C\u002Fcode> both widen to \u003Ccode>int\u003C\u002Fcode>, so \u003Ccode>&#39;A&#39;\u003C\u002Fcode> and the \u003Ccode>short\u003C\u002Fcode> holding 250 pick the \u003Ccode>int\u003C\u002Fcode> overload. The \u003Ca href=\"https:\u002F\u002Fdocs.oracle.com\u002Fjavase\u002Fspecs\u002Fjls\u002Fse21\u002Fhtml\u002Fjls-15.html\">language specification\u003C\u002Fa> describes the full rules in section 15.12.2.\u003C\u002Fp>\n\u003Ch2 id=\"before-the-next-article\">Before the next article\u003C\u002Fh2>\n\u003Cp>In the fixed \u003Ccode>Receipt.java\u003C\u002Fcode>, change \u003Ccode>int subtotal = 25000;\u003C\u002Fcode> to \u003Ccode>int subtotal = 40000;\u003C\u002Fcode>. Recompile it, run it, and pipe it into the same checker. The receipt prints \u003Ccode>subtotal: 40000\u003C\u002Fcode> and \u003Ccode>total: 37500\u003C\u002Fcode>. The checker reports \u003Ccode>0 of 2 checks passed\u003C\u002Fcode> and exits with status 1, because its two expected lines are fixed at 25000 and 22500.\u003C\u002Fp>\n\u003Cp>Both receipt lines are correct for a 40000 subtotal; the checker fails only because its expected output is hardcoded to 25000 and 22500.\u003C\u002Fp>\n","\u003Cul>\n\u003Cli>Java passes every argument by value, so a method that assigns to its parameter changes a copy and leaves the caller&#39;s variable alone.\u003C\u002Fli>\n\u003Cli>A \u003Ccode>void\u003C\u002Fcode> method returns nothing, so a value computed inside it is gone unless the method prints or stores it before it ends.\u003C\u002Fli>\n\u003Cli>The fixed version returns \u003Ccode>int\u003C\u002Fcode> and the caller assigns the result, which is what puts \u003Ccode>total: 22500\u003C\u002Fcode> on the receipt.\u003C\u002Fli>\n\u003Cli>An array argument is a copy of a reference, so \u003Ccode>prices[i] = ...\u003C\u002Fcode> changes the caller&#39;s elements while \u003Ccode>prices = new int[] {0, 0}\u003C\u002Fcode> moves only the copy.\u003C\u002Fli>\n\u003Cli>A \u003Ccode>double\u003C\u002Fcode> return type does not rescue integer division: \u003Ccode>sum \u002F count\u003C\u002Fcode> on two \u003Ccode>int\u003C\u002Fcode>s drops the fraction before the widening.\u003C\u002Fli>\n\u003Cli>Overloads are chosen at compile time from the declared argument types, so \u003Ccode>char\u003C\u002Fcode> and \u003Ccode>short\u003C\u002Fcode> both widen to \u003Ccode>int\u003C\u002Fcode> and pick the \u003Ccode>int\u003C\u002Fcode> overload.\u003C\u002Fli>\n\u003C\u002Ful>\n",[182,200,222,239,256,276],{"id":183,"title":184,"title_id":185,"slug":186,"excerpt":187,"excerpt_id":188,"has_translation":12,"published_at":189,"reading_time":190,"hidden_from_listing":15,"tags":191,"thumbnail_image":21,"og_image":195,"series":196,"authors":197},164,"Python Capstone: Why a Blank CSV Field Cut the Class Average","Python Capstone: Kenapa Satu Kolom CSV Kosong Memotong Rata-rata Kelas","python-capstone-gradebook","A gradebook reads four students and writes a JSON report. The class average says 52.42, because two empty fields became zeros.","Buku nilai membaca empat siswa dan menulis laporan JSON. Rata-rata kelasnya bilang 52.42, karena dua kolom kosong berubah jadi nol.","2026-11-21T01:00:00.000Z",8,[192,193,194],"python","input-output","cli","\u002Fog\u002Fpython-capstone-gradebook.png",{"id":165,"title":55,"title_id":56,"slug":57},[198],{"authors_id":199},{"id":110,"name":111,"slug":112,"role":113,"profile_picture":21},{"id":201,"title":202,"title_id":203,"slug":204,"excerpt":205,"excerpt_id":206,"has_translation":12,"published_at":189,"reading_time":207,"hidden_from_listing":15,"tags":208,"thumbnail_image":21,"og_image":213,"series":214,"authors":219},48,"What a Linked List Actually Is","Tentang Struktur Data LinkedList","tentang-struktur-data-linked-list","A linked list is a linear chain of nodes, each holding data and a pointer to the next node. Here is what that chain looks like, what it costs next to an array, and the same minimal implementation in Java, Python, and JavaScript.","Linked list adalah rantai linear berisi node, dan setiap node menyimpan data plus pointer ke node berikutnya. Ini bentuk rantainya, ongkosnya dibanding array, dan implementasi paling sederhana dalam Java, Python, serta JavaScript.",4,[209,210,211,212],"struktur-data","linked-list","pointer","konsep","\u002Fog\u002Ftentang-struktur-data-linked-list.png",{"id":215,"title":216,"title_id":217,"slug":218},28,"Linear Data Structures","Struktur Data Linear","asd-struktur-linear",[220],{"authors_id":221},{"id":110,"name":111,"slug":112,"role":113,"profile_picture":21},{"id":223,"title":224,"title_id":225,"slug":226,"excerpt":227,"excerpt_id":228,"has_translation":12,"published_at":229,"reading_time":102,"hidden_from_listing":15,"tags":230,"thumbnail_image":21,"og_image":234,"series":235,"authors":236},163,"Pascal Capstone: Why Every Gradebook Score Came Back Zero","Capstone Pascal: Kenapa Semua Skor Buku Nilai Kembali Nol","pascal-gradebook-capstone","A gradebook reads three students from a file, prints three rows, and every score is 0. The procedure filled a copy of the array, because the parameter was missing `var`. Add the word and the report matches the file; the compiler had already warned about the call that filled nothing.","Sebuah buku nilai membaca tiga siswa dari berkas, mencetak tiga baris, dan setiap skornya 0. Prosedurnya mengisi salinan array, karena parameternya kehilangan `var`. Tambahkan kata itu dan laporannya cocok dengan berkasnya; kompilator sudah memperingatkan soal pemanggilan yang tidak mengisi apa pun.","2026-11-20T01:00:00.000Z",[231,232,138,233],"pascal","record","prosedur","\u002Fog\u002Fpascal-gradebook-capstone.png",{"id":170,"title":67,"title_id":68,"slug":69},[237],{"authors_id":238},{"id":110,"name":111,"slug":112,"role":113,"profile_picture":21},{"id":240,"title":241,"title_id":242,"slug":243,"excerpt":244,"excerpt_id":245,"has_translation":12,"published_at":229,"reading_time":102,"hidden_from_listing":15,"tags":246,"thumbnail_image":21,"og_image":247,"series":248,"authors":253},162,"Python File I\u002FO: Why the Second Read Came Back Empty","Python File I\u002FO: Kenapa Pembacaan Kedua Kembali Kosong","python-file-read-write","A notes script saves a line, prints it back, then counts zero. The file on disk is correct: `read()` left the pointer at the end, so the second call returned an empty string. Read once into a variable, or `seek(0)`, and the count matches the file.","Skrip catatan menyimpan satu baris, mencetaknya kembali, lalu menghitung nol. Berkas di disk sudah benar: `read()` meninggalkan pointer di ujung, jadi panggilan kedua mengembalikan string kosong. Baca sekali ke sebuah variabel, atau `seek(0)`, dan hitungannya cocok dengan berkas.",[192,193],"\u002Fog\u002Fpython-file-read-write.png",{"id":249,"title":250,"title_id":251,"slug":252},18,"Working with Python Scripts","Menggunakan Script Python","python-pemrograman-dengan-script",[254],{"authors_id":255},{"id":110,"name":111,"slug":112,"role":113,"profile_picture":21},{"id":257,"title":258,"title_id":259,"slug":260,"excerpt":261,"excerpt_id":262,"has_translation":12,"published_at":263,"reading_time":84,"hidden_from_listing":15,"tags":264,"thumbnail_image":21,"og_image":267,"series":268,"authors":273},47,"Why Understanding Algorithms and Data Structures Actually Matters","Pentingnya Memahami Algoritma dan Struktur Data","pentingnya-memahami-algoritma-dan-struktur-data","An algorithm is an ordered list of steps, and that order decides how expensive a problem is. The examples are on the back of an instant noodle packet, in a factorial, and behind ctrl+z.","Sebagai konsep fundamental, algoritma menentukan seberapa mahal sebuah masalah diselesaikan. Contohnya ada di bungkus mie instan, di bilangan faktorial, dan di tombol undo.","2026-11-19T01:00:00.000Z",[265,209,212,266],"algoritma","dasar","\u002Fog\u002Fpentingnya-memahami-algoritma-dan-struktur-data.png",{"id":269,"title":270,"title_id":271,"slug":272},27,"About Algorithms and Data Structures","Tentang Algoritma dan Struktur Data","asd-intro",[274],{"authors_id":275},{"id":110,"name":111,"slug":112,"role":113,"profile_picture":21},{"id":277,"title":278,"title_id":279,"slug":280,"excerpt":281,"excerpt_id":282,"has_translation":12,"published_at":283,"reading_time":84,"hidden_from_listing":15,"tags":284,"thumbnail_image":21,"og_image":286,"series":287,"authors":288},161,"Debugging Free Pascal with -gl and gdb","Men-debug Free Pascal dengan -gl dan gdb","pascal-debugging-fpc-gdb","A run with no prices ends at a hex address and status 217. `-gl` names the line, gdb names the values, and the mean of six positive prices comes out negative because `integer` is 2 bytes.","Jalan tanpa satu harga pun berakhir di alamat hex dan status 217. `-gl` menyebut barisnya, gdb menyebut nilainya, dan rata-rata dari enam harga positif keluar negatif karena `integer` berukuran 2 byte.","2026-11-18T01:00:00.000Z",[231,285],"debugging","\u002Fog\u002Fpascal-debugging-fpc-gdb.png",{"id":170,"title":67,"title_id":68,"slug":69},[289],{"authors_id":290},{"id":110,"name":111,"slug":112,"role":113,"profile_picture":21},[292,296,299,302,305,308,311],{"text":293,"depth":294,"id":295},"The method that subtracts nothing",2,"the-method-that-subtracts-nothing",{"text":297,"depth":294,"id":298},"Why the caller's price never changes","why-the-caller-s-price-never-changes",{"text":300,"depth":294,"id":301},"A check you can run","a-check-you-can-run",{"text":303,"depth":294,"id":304},"Return the number and assign it","return-the-number-and-assign-it",{"text":306,"depth":294,"id":307},"The array that does change","the-array-that-does-change",{"text":309,"depth":294,"id":310},"Two methods with one name","two-methods-with-one-name",{"text":312,"depth":294,"id":313},"Before the next article","before-the-next-article",1795825297112]