[{"data":1,"prerenderedAt":311},["ShallowReactive",2],{"tag-labels":3,"site-header":4,"article-java-array-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},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",6,[86,87],"java","array","\u002Fog\u002Fjava-array.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,113,128,133],{"id":95,"title":96,"title_id":97,"slug":98,"excerpt":99,"excerpt_id":100,"has_translation":12,"published_at":101,"reading_time":84,"hidden_from_listing":15,"tags":102,"thumbnail_image":21,"og_image":104,"series":105,"authors":106},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",[86,103],"percabangan","\u002Fog\u002Fjava-switch.png",{"id":90,"title":63,"title_id":64,"slug":65},[107],{"authors_id":108},{"id":109,"name":110,"slug":111,"role":112,"profile_picture":21},1,"Daffa Izzuddin","izzudd","Writer",{"id":114,"title":115,"title_id":116,"slug":117,"excerpt":118,"excerpt_id":119,"has_translation":12,"published_at":120,"reading_time":84,"hidden_from_listing":15,"tags":121,"thumbnail_image":21,"og_image":123,"series":124,"authors":125},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,122],"loop","\u002Fog\u002Fjava-loops.png",{"id":90,"title":63,"title_id":64,"slug":65},[126],{"authors_id":127},{"id":109,"name":110,"slug":111,"role":112,"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":129,"authors":130},{"id":90,"title":63,"title_id":64,"slug":65},[131],{"authors_id":132},{"id":109,"name":110,"slug":111,"role":112,"profile_picture":21},{"id":134,"title":135,"title_id":136,"slug":137,"excerpt":138,"excerpt_id":139,"has_translation":12,"published_at":140,"reading_time":141,"hidden_from_listing":15,"tags":142,"thumbnail_image":21,"og_image":144,"series":145,"authors":146},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,143],"method","\u002Fog\u002Fjava-method.png",{"id":90,"title":63,"title_id":64,"slug":65},[147],{"authors_id":148},{"id":109,"name":110,"slug":111,"role":112,"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":109,"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":109,"name":110,"slug":111,"role":112,"profile_picture":21},"en",[174,176],"id","\nThe register prints an average of 63. The four scores recorded in it are 80, 75, 92 and 71, and they average 79.5. Nothing crashes and nothing warns. The program exits with status 0 and the number looks believable. A wrong answer like that is harder to catch than an error message, because you have no reason to go looking for it.\n\n## The program that counts an empty desk\n\nAn array is a fixed row of numbered slots, and `new int[5]` builds five of them. This program stores four scores in those five slots, adds them with a `for`-each loop, and prints the average.\n\n```java\n\u002F\u002F Scores.java\npublic class Scores {\n    public static void main(String[] args) {\n        int[] scores = new int[5];\n        scores[0] = 80;\n        scores[1] = 75;\n        scores[2] = 92;\n        scores[3] = 71;\n\n        int total = 0;\n        for (int score : scores) {\n            total += score;\n        }\n\n        System.out.println(\"students: \" + scores.length);\n        System.out.println(\"total: \" + total);\n        System.out.println(\"average: \" + total \u002F scores.length);\n    }\n}\n```\n\n```plain\n$ javac Scores.java && java Scores\nstudents: 5\ntotal: 318\naverage: 63\n```\n\nThe total is right, because 80, 75, 92 and 71 do add to 318. The average is wrong. The division gives 63.6, and the program prints 63 because both operands are `int`, so the fraction is dropped. Even 63.6 would be wrong, since the four real scores average 79.5.\n\n## Why every slot starts at zero\n\nCreating an `int` array fills every slot with 0. After `int[] scores = new int[5];`, the statement `System.out.println(scores[4]);` prints `0`. The program above never assigns `scores[4]`, so the fifth slot still holds that zero.\n\nThink of five desks in a classroom with only four students seated. The loop walks all five desks and adds whatever it finds. The empty desk adds 0, which leaves the total unchanged, so 318 survives. The damage comes from `scores.length`. It counts slots, not scores, so the division treats the empty desk as a fifth student who scored 0.\n\nThe loop cannot tell a stored 0 from a slot nobody touched. Both look identical, so the program has to track how many scores it actually entered.\n\n## A check you can run\n\nReading output by eye is how a wrong average survives. A small checker can compare it with the numbers you expect. This one reads the program's output line by line and compares each line with four expected lines.\n\n```java\n\u002F\u002F CheckScores.java\nimport java.util.List;\nimport java.util.Scanner;\n\npublic class CheckScores {\n    public static void main(String[] args) {\n        List\u003CString> expected = List.of(\"entries: 4\", \"slots: 5\", \"total: 318\", \"average: 79.5\");\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\n```plain\n$ javac CheckScores.java && java Scores | java CheckScores\nFAIL  line 1: expected entries: 4, got students: 5\nFAIL  line 2: expected slots: 5, got total: 318\nFAIL  line 3: expected total: 318, got average: 63\nFAIL  line 4: expected average: 79.5, got \u003Cnothing>\n\n0 of 4 checks passed\n```\n\nThe checker exits with status 1. The starter prints three lines where the checker wants four, so the fourth line fails with `\u003Cnothing>`. The red run also shows what the program never reports: how many scores were entered. The expected `entries: 4` points straight at the missing number.\n\n## Count the scores, not the slots\n\nThe fix keeps all five slots. It adds a counter named `filled` for the scores actually entered, and the loop and the division both use it.\n\n```java\n\u002F\u002F Scores.java\npublic class Scores {\n    public static void main(String[] args) {\n        int[] scores = new int[5];\n        int filled = 0;\n        scores[filled++] = 80;\n        scores[filled++] = 75;\n        scores[filled++] = 92;\n        scores[filled++] = 71;\n\n        int total = 0;\n        for (int i = 0; i \u003C filled; i++) {\n            total += scores[i];\n        }\n\n        System.out.println(\"entries: \" + filled);\n        System.out.println(\"slots: \" + scores.length);\n        System.out.println(\"total: \" + total);\n        System.out.println(\"average: \" + (double) total \u002F filled);\n    }\n}\n```\n\nIn `scores[filled++]`, the current value of `filled` picks the slot, and then `filled` goes up by one. After four assignments `filled` is 4, while `scores.length` stays 5. The loop stops at `filled`, so the empty fifth slot never enters the sum. The cast in `(double) total \u002F filled` moves the division into floating point, which is why the average prints `79.5` instead of `79`.\n\n```plain\n$ javac Scores.java && java Scores\nentries: 4\nslots: 5\ntotal: 318\naverage: 79.5\n```\n\n```plain\n$ java Scores | java CheckScores\nPASS  line 1: entries: 4\nPASS  line 2: slots: 5\nPASS  line 3: total: 318\nPASS  line 4: average: 79.5\n\n4 of 4 checks passed\n```\n\nBoth versions keep five slots. The only difference is which number the loop and the division use.\n\n## What the array will not do\n\nThe length of an array is fixed when `new int[5]` runs. No method on an array makes it longer. Store a sixth score in a five-slot array and the program fails loudly.\n\n```java\n\u002F\u002F Six.java\npublic class Six {\n    public static void main(String[] args) {\n        int[] scores = new int[5];\n        scores[0] = 80;\n        scores[1] = 75;\n        scores[2] = 92;\n        scores[3] = 71;\n        scores[4] = 68;\n        scores[5] = 88;\n        System.out.println(\"six scores stored\");\n    }\n}\n```\n\n```plain\n$ javac Six.java && java Six\nException in thread \"main\" java.lang.ArrayIndexOutOfBoundsException: Index 5 out of bounds for length 5\n\tat Six.main(Six.java:10)\n```\n\nThis failure is the opposite of the silent average. Java stops the program and names the index and the length.\n\nNotice also that `scores.length` has no parentheses. It reports the number of slots and is not a method call.\n\n## Change one score\n\nChange the 71 to 65 in the fixed version and run the unchanged checker.\n\nThe expected values in the checker are hardcoded, so it tests the input as much as the code. With 65 in place of 71 the fixed program still prints correct arithmetic, `total: 312` and `average: 78.0`, and the unchanged checker reports `2 of 4 checks passed` because two of its four expected lines now describe a class that no longer exists. If the class gains a sixth student, you have to allocate a larger array because `scores.length` stays fixed at 5.\n","- `new int[5]` fills all five slots with 0, so a slot you never assigned is indistinguishable from a real score of zero.\n- Adding zeros does not change the total, which is why `total: 318` stays correct while `average: 63` is wrong.\n- `scores.length` counts slots, not scores, so dividing by it treats the empty slot as a student.\n- A `filled` counter fixes both the loop bound and the division, and `(double) total \u002F filled` stops the fraction being dropped.\n- The array's length is fixed when `new int[5]` runs, so a sixth score throws `ArrayIndexOutOfBoundsException: Index 5 out of bounds for length 5`.\n- A checker with hardcoded expectations fails on correct code when the scores change, so it tests its input as much as your program.","\u003Cp>The register prints an average of 63. The four scores recorded in it are 80, 75, 92 and 71, and they average 79.5. Nothing crashes and nothing warns. The program exits with status 0 and the number looks believable. A wrong answer like that is harder to catch than an error message, because you have no reason to go looking for it.\u003C\u002Fp>\n\u003Ch2 id=\"the-program-that-counts-an-empty-desk\">The program that counts an empty desk\u003C\u002Fh2>\n\u003Cp>An array is a fixed row of numbered slots, and \u003Ccode>new int[5]\u003C\u002Fcode> builds five of them. This program stores four scores in those five slots, adds them with a \u003Ccode>for\u003C\u002Fcode>-each loop, and prints the average.\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%20Scores.java%0Apublic%20class%20Scores%20%7B%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%20scores%20%3D%20new%20int%5B5%5D%3B%0A%20%20%20%20%20%20%20%20scores%5B0%5D%20%3D%2080%3B%0A%20%20%20%20%20%20%20%20scores%5B1%5D%20%3D%2075%3B%0A%20%20%20%20%20%20%20%20scores%5B2%5D%20%3D%2092%3B%0A%20%20%20%20%20%20%20%20scores%5B3%5D%20%3D%2071%3B%0A%0A%20%20%20%20%20%20%20%20int%20total%20%3D%200%3B%0A%20%20%20%20%20%20%20%20for%20(int%20score%20%3A%20scores)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20total%20%2B%3D%20score%3B%0A%20%20%20%20%20%20%20%20%7D%0A%0A%20%20%20%20%20%20%20%20System.out.println(%22students%3A%20%22%20%2B%20scores.length)%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%20%20%20%20System.out.println(%22average%3A%20%22%20%2B%20total%20%2F%20scores.length)%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 Scores.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\"> Scores\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:#F97583\">        int\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">[] scores \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\">5\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">];\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        scores[\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">0\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">] \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\"> 80\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">;\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        scores[\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">1\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">] \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\"> 75\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">;\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        scores[\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">2\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">] \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\"> 92\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">;\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        scores[\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">3\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">] \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\"> 71\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">;\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\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:#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\"> score \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">:\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> scores) {\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\"> score;\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:#E1E4E8\">        System.out.\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">println\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"students: \"\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> +\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> scores.length);\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\">        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:#E1E4E8\"> total \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">\u002F\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> scores.length);\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%20Scores.java%20%26%26%20java%20Scores%0Astudents%3A%205%0Atotal%3A%20318%0Aaverage%3A%2063\" 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 Scores.java &amp;&amp; java Scores\u003C\u002Fspan>\nstudents: 5\ntotal: 318\naverage: 63\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\u003Cp>The total is right, because 80, 75, 92 and 71 do add to 318. The average is wrong. The division gives 63.6, and the program prints 63 because both operands are \u003Ccode>int\u003C\u002Fcode>, so the fraction is dropped. Even 63.6 would be wrong, since the four real scores average 79.5.\u003C\u002Fp>\n\u003Ch2 id=\"why-every-slot-starts-at-zero\">Why every slot starts at zero\u003C\u002Fh2>\n\u003Cp>Creating an \u003Ccode>int\u003C\u002Fcode> array fills every slot with 0. After \u003Ccode>int[] scores = new int[5];\u003C\u002Fcode>, the statement \u003Ccode>System.out.println(scores[4]);\u003C\u002Fcode> prints \u003Ccode>0\u003C\u002Fcode>. The program above never assigns \u003Ccode>scores[4]\u003C\u002Fcode>, so the fifth slot still holds that zero.\u003C\u002Fp>\n\u003Cp>Think of five desks in a classroom with only four students seated. The loop walks all five desks and adds whatever it finds. The empty desk adds 0, which leaves the total unchanged, so 318 survives. The damage comes from \u003Ccode>scores.length\u003C\u002Fcode>. It counts slots, not scores, so the division treats the empty desk as a fifth student who scored 0.\u003C\u002Fp>\n\u003Cp>The loop cannot tell a stored 0 from a slot nobody touched. Both look identical, so the program has to track how many scores it actually entered.\u003C\u002Fp>\n\u003Ch2 id=\"a-check-you-can-run\">A check you can run\u003C\u002Fh2>\n\u003Cp>Reading output by eye is how a wrong average survives. A small checker can compare it with the numbers you expect. This one reads the program&#39;s output line by line and compares each line with four expected lines.\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%20CheckScores.java%0Aimport%20java.util.List%3B%0Aimport%20java.util.Scanner%3B%0A%0Apublic%20class%20CheckScores%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(%22entries%3A%204%22%2C%20%22slots%3A%205%22%2C%20%22total%3A%20318%22%2C%20%22average%3A%2079.5%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 CheckScores.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\"> CheckScores\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\">\"entries: 4\"\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">, \u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"slots: 5\"\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">, \u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"total: 318\"\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">, \u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"average: 79.5\"\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>\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%20CheckScores.java%20%26%26%20java%20Scores%20%7C%20java%20CheckScores%0AFAIL%20%20line%201%3A%20expected%20entries%3A%204%2C%20got%20students%3A%205%0AFAIL%20%20line%202%3A%20expected%20slots%3A%205%2C%20got%20total%3A%20318%0AFAIL%20%20line%203%3A%20expected%20total%3A%20318%2C%20got%20average%3A%2063%0AFAIL%20%20line%204%3A%20expected%20average%3A%2079.5%2C%20got%20%3Cnothing%3E%0A%0A0%20of%204%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 CheckScores.java &amp;&amp; java Scores | java CheckScores\u003C\u002Fspan>\nFAIL  line 1: expected entries: 4, got students: 5\nFAIL  line 2: expected slots: 5, got total: 318\nFAIL  line 3: expected total: 318, got average: 63\nFAIL  line 4: expected average: 79.5, got &lt;nothing&gt;\n\n0 of 4 checks passed\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\u003Cp>The checker exits with status 1. The starter prints three lines where the checker wants four, so the fourth line fails with \u003Ccode>&lt;nothing&gt;\u003C\u002Fcode>. The red run also shows what the program never reports: how many scores were entered. The expected \u003Ccode>entries: 4\u003C\u002Fcode> points straight at the missing number.\u003C\u002Fp>\n\u003Ch2 id=\"count-the-scores-not-the-slots\">Count the scores, not the slots\u003C\u002Fh2>\n\u003Cp>The fix keeps all five slots. It adds a counter named \u003Ccode>filled\u003C\u002Fcode> for the scores actually entered, and the loop and the division both use it.\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%20Scores.java%0Apublic%20class%20Scores%20%7B%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%20scores%20%3D%20new%20int%5B5%5D%3B%0A%20%20%20%20%20%20%20%20int%20filled%20%3D%200%3B%0A%20%20%20%20%20%20%20%20scores%5Bfilled%2B%2B%5D%20%3D%2080%3B%0A%20%20%20%20%20%20%20%20scores%5Bfilled%2B%2B%5D%20%3D%2075%3B%0A%20%20%20%20%20%20%20%20scores%5Bfilled%2B%2B%5D%20%3D%2092%3B%0A%20%20%20%20%20%20%20%20scores%5Bfilled%2B%2B%5D%20%3D%2071%3B%0A%0A%20%20%20%20%20%20%20%20int%20total%20%3D%200%3B%0A%20%20%20%20%20%20%20%20for%20(int%20i%20%3D%200%3B%20i%20%3C%20filled%3B%20i%2B%2B)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20total%20%2B%3D%20scores%5Bi%5D%3B%0A%20%20%20%20%20%20%20%20%7D%0A%0A%20%20%20%20%20%20%20%20System.out.println(%22entries%3A%20%22%20%2B%20filled)%3B%0A%20%20%20%20%20%20%20%20System.out.println(%22slots%3A%20%22%20%2B%20scores.length)%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%20%20%20%20System.out.println(%22average%3A%20%22%20%2B%20(double)%20total%20%2F%20filled)%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 Scores.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\"> Scores\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:#F97583\">        int\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">[] scores \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\">5\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\"> filled \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:#E1E4E8\">        scores[filled\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">++\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">] \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\"> 80\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">;\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        scores[filled\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">++\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">] \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\"> 75\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">;\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        scores[filled\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">++\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">] \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\"> 92\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">;\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        scores[filled\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">++\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">] \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\"> 71\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">;\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\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:#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\"> filled; 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\">            total \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">+=\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> scores[i];\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:#E1E4E8\">        System.out.\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">println\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"entries: \"\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> +\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> filled);\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\">\"slots: \"\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> +\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> scores.length);\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\">        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:#E1E4E8\"> (\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">double\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">) total \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">\u002F\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> filled);\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>In \u003Ccode>scores[filled++]\u003C\u002Fcode>, the current value of \u003Ccode>filled\u003C\u002Fcode> picks the slot, and then \u003Ccode>filled\u003C\u002Fcode> goes up by one. After four assignments \u003Ccode>filled\u003C\u002Fcode> is 4, while \u003Ccode>scores.length\u003C\u002Fcode> stays 5. The loop stops at \u003Ccode>filled\u003C\u002Fcode>, so the empty fifth slot never enters the sum. The cast in \u003Ccode>(double) total \u002F filled\u003C\u002Fcode> moves the division into floating point, which is why the average prints \u003Ccode>79.5\u003C\u002Fcode> instead of \u003Ccode>79\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%20Scores.java%20%26%26%20java%20Scores%0Aentries%3A%204%0Aslots%3A%205%0Atotal%3A%20318%0Aaverage%3A%2079.5\" 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 Scores.java &amp;&amp; java Scores\u003C\u002Fspan>\nentries: 4\nslots: 5\ntotal: 318\naverage: 79.5\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%20Scores%20%7C%20java%20CheckScores%0APASS%20%20line%201%3A%20entries%3A%204%0APASS%20%20line%202%3A%20slots%3A%205%0APASS%20%20line%203%3A%20total%3A%20318%0APASS%20%20line%204%3A%20average%3A%2079.5%0A%0A4%20of%204%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 Scores | java CheckScores\u003C\u002Fspan>\nPASS  line 1: entries: 4\nPASS  line 2: slots: 5\nPASS  line 3: total: 318\nPASS  line 4: average: 79.5\n\n4 of 4 checks passed\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\u003Cp>Both versions keep five slots. The only difference is which number the loop and the division use.\u003C\u002Fp>\n\u003Ch2 id=\"what-the-array-will-not-do\">What the array will not do\u003C\u002Fh2>\n\u003Cp>The length of an array is fixed when \u003Ccode>new int[5]\u003C\u002Fcode> runs. No method on an array makes it longer. Store a sixth score in a five-slot array and the program fails loudly.\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%20Six.java%0Apublic%20class%20Six%20%7B%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%20scores%20%3D%20new%20int%5B5%5D%3B%0A%20%20%20%20%20%20%20%20scores%5B0%5D%20%3D%2080%3B%0A%20%20%20%20%20%20%20%20scores%5B1%5D%20%3D%2075%3B%0A%20%20%20%20%20%20%20%20scores%5B2%5D%20%3D%2092%3B%0A%20%20%20%20%20%20%20%20scores%5B3%5D%20%3D%2071%3B%0A%20%20%20%20%20%20%20%20scores%5B4%5D%20%3D%2068%3B%0A%20%20%20%20%20%20%20%20scores%5B5%5D%20%3D%2088%3B%0A%20%20%20%20%20%20%20%20System.out.println(%22six%20scores%20stored%22)%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 Six.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\"> Six\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:#F97583\">        int\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">[] scores \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\">5\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">];\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        scores[\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">0\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">] \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\"> 80\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">;\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        scores[\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">1\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">] \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\"> 75\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">;\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        scores[\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">2\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">] \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\"> 92\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">;\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        scores[\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">3\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">] \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\"> 71\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">;\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        scores[\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">4\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">] \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\"> 68\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">;\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        scores[\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">5\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">] \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\"> 88\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\">\"six scores stored\"\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%20Six.java%20%26%26%20java%20Six%0AException%20in%20thread%20%22main%22%20java.lang.ArrayIndexOutOfBoundsException%3A%20Index%205%20out%20of%20bounds%20for%20length%205%0A%09at%20Six.main(Six.java%3A10)\" 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 Six.java &amp;&amp; java Six\u003C\u002Fspan>\nException in thread \"main\" java.lang.ArrayIndexOutOfBoundsException: Index 5 out of bounds for length 5\n\tat Six.main(Six.java:10)\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\u003Cp>This failure is the opposite of the silent average. Java stops the program and names the index and the length.\u003C\u002Fp>\n\u003Cp>Notice also that \u003Ccode>scores.length\u003C\u002Fcode> has no parentheses. It reports the number of slots and is not a method call.\u003C\u002Fp>\n\u003Ch2 id=\"change-one-score\">Change one score\u003C\u002Fh2>\n\u003Cp>Change the 71 to 65 in the fixed version and run the unchanged checker.\u003C\u002Fp>\n\u003Cp>The expected values in the checker are hardcoded, so it tests the input as much as the code. With 65 in place of 71 the fixed program still prints correct arithmetic, \u003Ccode>total: 312\u003C\u002Fcode> and \u003Ccode>average: 78.0\u003C\u002Fcode>, and the unchanged checker reports \u003Ccode>2 of 4 checks passed\u003C\u002Fcode> because two of its four expected lines now describe a class that no longer exists. If the class gains a sixth student, you have to allocate a larger array because \u003Ccode>scores.length\u003C\u002Fcode> stays fixed at 5.\u003C\u002Fp>\n","\u003Cul>\n\u003Cli>\u003Ccode>new int[5]\u003C\u002Fcode> fills all five slots with 0, so a slot you never assigned is indistinguishable from a real score of zero.\u003C\u002Fli>\n\u003Cli>Adding zeros does not change the total, which is why \u003Ccode>total: 318\u003C\u002Fcode> stays correct while \u003Ccode>average: 63\u003C\u002Fcode> is wrong.\u003C\u002Fli>\n\u003Cli>\u003Ccode>scores.length\u003C\u002Fcode> counts slots, not scores, so dividing by it treats the empty slot as a student.\u003C\u002Fli>\n\u003Cli>A \u003Ccode>filled\u003C\u002Fcode> counter fixes both the loop bound and the division, and \u003Ccode>(double) total \u002F filled\u003C\u002Fcode> stops the fraction being dropped.\u003C\u002Fli>\n\u003Cli>The array&#39;s length is fixed when \u003Ccode>new int[5]\u003C\u002Fcode> runs, so a sixth score throws \u003Ccode>ArrayIndexOutOfBoundsException: Index 5 out of bounds for length 5\u003C\u002Fcode>.\u003C\u002Fli>\n\u003Cli>A checker with hardcoded expectations fails on correct code when the scores change, so it tests its input as much as your program.\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":109,"name":110,"slug":111,"role":112,"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":109,"name":110,"slug":111,"role":112,"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":84,"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,87,233],"pascal","record","prosedur","\u002Fog\u002Fpascal-gradebook-capstone.png",{"id":170,"title":67,"title_id":68,"slug":69},[237],{"authors_id":238},{"id":109,"name":110,"slug":111,"role":112,"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":84,"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":109,"name":110,"slug":111,"role":112,"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":141,"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":109,"name":110,"slug":111,"role":112,"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":141,"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":109,"name":110,"slug":111,"role":112,"profile_picture":21},[292,296,299,302,305,308],{"text":293,"depth":294,"id":295},"The program that counts an empty desk",2,"the-program-that-counts-an-empty-desk",{"text":297,"depth":294,"id":298},"Why every slot starts at zero","why-every-slot-starts-at-zero",{"text":300,"depth":294,"id":301},"A check you can run","a-check-you-can-run",{"text":303,"depth":294,"id":304},"Count the scores, not the slots","count-the-scores-not-the-slots",{"text":306,"depth":294,"id":307},"What the array will not do","what-the-array-will-not-do",{"text":309,"depth":294,"id":310},"Change one score","change-one-score",1795825297011]