<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
    <channel>
      <title>Cy | Space</title>
      <link>https://cybar.dev</link>
      <description>A home for my thoughts</description>
      <generator>Zola</generator>
      <language>en</language>
      <atom:link href="https://cybar.dev/rss.xml" rel="self" type="application/rss+xml"/>
      <lastBuildDate>Mon, 11 May 2026 20:00:00 +0000</lastBuildDate>
      <item>
          <title>Losing Touch</title>
          <pubDate>Mon, 11 May 2026 20:00:00 +0000</pubDate>
          <author>cybardev</author>
          <link>https://cybar.dev/blog/losing-touch/</link>
          <guid>https://cybar.dev/blog/losing-touch/</guid>
          <description xml:base="https://cybar.dev/blog/losing-touch/">&lt;p&gt;Ever felt yourself changing at a fundamental level, and slowly becoming a different person? Slowly... being unable to recognize yourself, becoming a stranger to your own mind?&lt;&#x2F;p&gt;
&lt;p&gt;I hear adolescence is like that. But, maybe because I was so sheltered, it&#x27;s only taking effect now.&lt;&#x2F;p&gt;
&lt;p&gt;I don&#x27;t code anymore... at least, not as much as I used to. I don&#x27;t feel motivated to. It feels like I lost a core part of myself. Coding was the fibre of my being. Without code, who am I? It&#x27;s something I&#x27;m having to come to terms with these days.&lt;&#x2F;p&gt;
&lt;p&gt;It&#x27;s good to diversify, not just in investing, but also in interests. Though, it didn&#x27;t feel like it was in my control. Events in my life naturally led me to feel connected with coding; I couldn&#x27;t just artificially grow feelings for new hobbies; at least not to the level of my affinity with coding.&lt;&#x2F;p&gt;
&lt;p&gt;What is in my control, though, is &quot;to love it enough to let it go&quot;. Nothing in life lasts forever; it&#x27;s sad to see it pass me by, but I&#x27;m glad I ever did cross paths with it. Best I can do is keep experiencing life as it comes to me, and exploring my abilities however opportunity presents.&lt;&#x2F;p&gt;
&lt;p&gt;Ofc, I will keep coding, when it comes to me naturally. But gone are the days of losing myself in projects, building, solving problems in my life with code. As life went on, my problems diminished (Alhamdulillah), but that did lead to some level of monotone. I do have some ideas of what I want to do next tho. Hopefully I&#x27;ll find new love in something, or someone...&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>Mini Homelab Self-hosting Setup</title>
          <pubDate>Sat, 21 Mar 2026 16:00:00 +0000</pubDate>
          <author>cybardev</author>
          <link>https://cybar.dev/blog/mini-homelab/</link>
          <guid>https://cybar.dev/blog/mini-homelab/</guid>
          <description xml:base="https://cybar.dev/blog/mini-homelab/">&lt;p&gt;Over December 2025 I set up a homelab with most of the cloud services I often use, on an old netbook that&#x27;s weaker than a modern Raspberry Pi board. Since then it has evolved a bit too. This post is to document how I did it, why I did it, and what&#x27;s in store for the setup going forward. Here, I&#x27;ll share my experiences and decisions. If you&#x27;re interested in setting up your own homelab, I hope this will serve as a useful guide and inspiration. Follow along with the code: &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;cybardev&#x2F;homelab&quot;&gt;github.com&#x2F;cybardev&#x2F;homelab&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;media.cybar.dev&#x2F;site&#x2F;mini-homelab.webp&quot; title=&quot;Container%20Resource%20Usage&quot; alt=&quot;Screenshot of output from nerdctl stats, showing resource usage stats from currently running containers on my homelab setup&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;h2 id=&quot;&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#&quot; aria-label=&quot;Anchor link for: &quot;&gt;Why&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;Privacy is an obvious point, and a common reason why people do this. For me it was a bit of that, but more so about keeping things more in my control. With tons of rugpulls all across the media and gaming industry, I just didn&amp;#39;t want to wake up one day and find out my data is at risk of being deleted or held ransom and having to desperately scramble to move everything elsewhere in a race against time. It&amp;#39;s just more comforting to know my stuff is physically around me, and&#x2F;or even if it&amp;#39;s (replicated) elsewhere, I&amp;#39;d have a copy of it. Also ended up being a nice learning experience, with lessons in container orchestration, resource management, niche Linux, and computer networking — all valuable skills, from what I&amp;#39;ve been informed.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;-1&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#-1&quot; aria-label=&quot;Anchor link for: -1&quot;&gt;What&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;Here&amp;#39;s the services I host&#x2F;ed on my homelab. I say &amp;quot;host&#x2F;ed&amp;quot; because some of them may not be there anymore because I either wanted to dedicate resources to something else, or switched to one or more alternatives (in any case, they&amp;#39;re all listed, so you may find services with overlapping purpose).&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;searxng&#x2F;searxng&quot;&gt;SearXNG&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;forgejo.org&#x2F;&quot;&gt;Forgejo&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;nextcloud.com&#x2F;&quot;&gt;Nextcloud&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;dani-garcia&#x2F;vaultwarden&quot;&gt;Vaultwarden&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;developers.cloudflare.com&#x2F;cloudflare-one&#x2F;networks&#x2F;connectors&#x2F;cloudflare-tunnel&#x2F;&quot;&gt;Cloudflare Tunnel&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;cybardev&#x2F;cybarbot&quot;&gt;Cy | bot&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;cloudreve.org&#x2F;&quot;&gt;Cloudreve&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;radicale.org&#x2F;v3.html&quot;&gt;Radicale&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;imputnet&#x2F;cobalt&quot;&gt;Cobalt&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;ente.io&#x2F;&quot;&gt;Ente&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;tailscale.com&#x2F;&quot;&gt;Tailscale&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;4get.ca&#x2F;&quot;&gt;4get&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;nicolargo&#x2F;glances&quot;&gt;Glances&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;&lt;strong&gt;PS&lt;&#x2F;strong&gt;: Some of these depend on services like a database or cache. I mostly stuck to &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;www.postgresql.org&#x2F;&quot;&gt;PostgreSQL&lt;&#x2F;a&gt; and &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;valkey.io&#x2F;&quot;&gt;Valkey&lt;&#x2F;a&gt; (a Redis fork).&lt;&#x2F;p&gt;
&lt;h2 id=&quot;-2&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#-2&quot; aria-label=&quot;Anchor link for: -2&quot;&gt;How&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;I will go over my thought process for how I selected which services to use, but if you want to dive right into the Compose files and guidance on how to set them up for yourself, here&amp;#39;s the repository: &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;cybardev&#x2F;homelab&quot;&gt;github.com&#x2F;cybardev&#x2F;homelab&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3 id=&quot;-3&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#-3&quot; aria-label=&quot;Anchor link for: -3&quot;&gt;Hardware&lt;&#x2F;a&gt;&lt;&#x2F;h3&gt;
&lt;p&gt;&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Acer_Aspire_One&quot;&gt;Acer Aspire One Happy 2&lt;&#x2F;a&gt; (2011) netbook laptop, with a single-core 1.66 GHz Intel Atom N450 and 1 GB of DDR2 RAM. Originally it had a 160 GB Seagate hard drive, but I later upgraded to a 1 TB HDD, and most recently, a 250 GB SSD, which it is currently using.&lt;&#x2F;p&gt;
&lt;p&gt;Didn&amp;#39;t have much to choose from. I just had my main laptop and this, and didn&amp;#39;t want to buy anything new (for now). I do have another old laptop with much better spec, but last I tried it didn&amp;#39;t boot. Might try again later. For now I want to focus on low power consumption and few high-priority services, though I&amp;#39;m increasingly feeling the need for more available RAM...&lt;&#x2F;p&gt;
&lt;h3 id=&quot;-4&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#-4&quot; aria-label=&quot;Anchor link for: -4&quot;&gt;Operating System&lt;&#x2F;a&gt;&lt;&#x2F;h3&gt;
&lt;p&gt;Given the humble hardware, I needed to choose something extremely lightweight. I wanted to choose one of the container-based distros like &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;microos.opensuse.org&#x2F;&quot;&gt;OpenSUSE MicroOS&lt;&#x2F;a&gt;, or &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;fedoraproject.org&#x2F;coreos&#x2F;&quot;&gt;Fedora CoreOS&lt;&#x2F;a&gt;, but the requirements still seemed a bit above what I could offer. So I settled on &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;www.alpinelinux.org&#x2F;&quot;&gt;Alpine Linux&lt;&#x2F;a&gt;, which has been pretty solid. Some things are quirky, like &lt;code&gt;doas&lt;&#x2F;code&gt; instead of &lt;code&gt;sudo&lt;&#x2F;code&gt;, and the lack of &lt;code&gt;systemd&lt;&#x2F;code&gt; conveniences; but nothing showstopping.&lt;&#x2F;p&gt;
&lt;p&gt;Ideally I would like to use &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;nixos.org&#x2F;&quot;&gt;NixOS&lt;&#x2F;a&gt;. That way I could deploy the services using NixOS modules, cutting out the middleman (containers). I will probably try that when I get the other laptop to work.&lt;&#x2F;p&gt;
&lt;p&gt;Alternatively, I might install &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;fedoraproject.org&#x2F;server&#x2F;&quot;&gt;Fedora Server&lt;&#x2F;a&gt; (yes, the regular one, not CoreOS) or &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;rockylinux.org&#x2F;&quot;&gt;Rocky Linux&lt;&#x2F;a&gt; or &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;almalinux.org&#x2F;&quot;&gt;AlmaLinux&lt;&#x2F;a&gt;, and put &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;kind.sigs.k8s.io&#x2F;&quot;&gt;Kubernetes (kind)&lt;&#x2F;a&gt; on top. It&amp;#39;s likely overkill for my purposes, but I want to use this as an opportunity to learn hands-on how to provision infrastructure using &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;developer.hashicorp.com&#x2F;terraform&#x2F;tutorials&#x2F;kubernetes&#x2F;kubernetes-provider&quot;&gt;Terraform&lt;&#x2F;a&gt;, set up a production environment using &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;ansible&#x2F;ansible&quot;&gt;Ansible&lt;&#x2F;a&gt;, orchestrate containerized services with redundancy through replication and load-balancing using Kubernetes, all on an OS that&amp;#39;s similar to the industry standard &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;www.redhat.com&#x2F;en&#x2F;technologies&#x2F;linux-platforms&#x2F;enterprise-linux&quot;&gt;Red Hat Enterprise Linux (RHEL)&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;CoreOS would make it more convenient, but then I don&amp;#39;t learn as much. For me, that&amp;#39;s the fun part.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;-5&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#-5&quot; aria-label=&quot;Anchor link for: -5&quot;&gt;Network Proxy&lt;&#x2F;a&gt;&lt;&#x2F;h3&gt;
&lt;p&gt;It wouldn&amp;#39;t be too useful if I was out and about, and couldn&amp;#39;t use my services. I needed a way to forward the active ports while not having a static IP. There&amp;#39;s various ways of doing that: Cloudflare Tunnel, Tailscale, WireGuard, Dynamic DNS + Reverse Proxy (like &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;nginx.org&#x2F;en&#x2F;&quot;&gt;nginx&lt;&#x2F;a&gt;); to name a few.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;developers.cloudflare.com&#x2F;cloudflare-one&#x2F;networks&#x2F;connectors&#x2F;cloudflare-tunnel&#x2F;&quot;&gt;Cloudflare Tunnel&lt;&#x2F;a&gt; is what I started with. My domain is on Cloudflare, and the web UI is very simple to use. I was all set up in a few clicks (after starting the server container in host network mode, ofc). The issue, tho, is that Cloudflare makes the services &lt;em&gt;public&lt;&#x2F;em&gt;. That is, anyone who knows the URL can use the service. This would not be an issue for most things due to auth, and I would actually like some services to be public use (like SearXNG). But on a 1 core CPU with &amp;lt;1GB RAM... it gets a bit iffy if many people try to use it simultaneously. So until I upgrade my hardware, I needed to keep my services to myself...&lt;&#x2F;p&gt;
&lt;p&gt;Enter &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;tailscale.com&#x2F;&quot;&gt;Tailscale&lt;&#x2F;a&gt;. Tailscale is a VPN that uses WireGuard under the hood. It basically takes the setup step out of &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;www.wireguard.com&#x2F;&quot;&gt;WireGuard&lt;&#x2F;a&gt;, providing a premade subset and&#x2F;or superset of the features that works for many cases. If one needs finer control, WireGuard may be a better solution, but for my purposes this is fine (at least for now). Tailscale proxies my server&amp;#39;s local network over the internet, through their servers, to whatever other devices are connected to the same &amp;quot;Tailnet&amp;quot;, which is just their marketing term for a VPN. I use Tailscale clients on my main laptop and my phone, and only those devices (client and server both must be aithn&amp;#39;d to my Tailscale account) can access the URLs of my services (while connected to the VPN) that are hosted on the server. The Tailscale server software is also running as a compose container, with host-mode networking.&lt;&#x2F;p&gt;
&lt;p&gt;I could directly use WireGuard, but that would be more effort than I&amp;#39;m willing to invest at the moment. Same issue with DDNS and reverse proxy. I might revisit this in the future, even if at least for the sake of learning how those go.&lt;&#x2F;p&gt;
&lt;p&gt;The endgame idea I have is to rent a VPS and host &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;juanfont&#x2F;headscale&quot;&gt;Headscale&lt;&#x2F;a&gt; there, thus having (mostly) full control of the network traffic. Headscale is... well, Tailscale&amp;#39;s client software (even the servers are actually clients, since they connect to the Tailscale backend) is open-source; but Tailscale&amp;#39;s backend, the parts that actually route the network traffic, is proprietary (this is my understanding; feel free to correct me), so some person&#x2F;folks in the community made Headscale, which can act as that routing backend. It needs a static IP though, so a VPS would be needed, if static IP can&amp;#39;t be acquired from the ISP. I&amp;#39;ll see what I do when I get to it.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;-6&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#-6&quot; aria-label=&quot;Anchor link for: -6&quot;&gt;Search Engine&lt;&#x2F;a&gt;&lt;&#x2F;h3&gt;
&lt;p&gt;If you&amp;#39;ve read my last post (&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;cybar.dev&#x2F;blog&#x2F;selfhost-searxng&#x2F;&quot;&gt;cybar.dev&#x2F;blog&#x2F;selfhost-searxng&lt;&#x2F;a&gt;), you&amp;#39;re already familiar with what I&amp;#39;m doing for this. The only difference is that previously I was hosting it on my main laptop using a Home Manager Nix module, while now it&amp;#39;s using a Docker Compose file running on the potato &amp;quot;server&amp;quot;. Also wasn&amp;#39;t using a cache previously but now there&amp;#39;s Valkey.&lt;&#x2F;p&gt;
&lt;p&gt;I did give &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;4get.ca&#x2F;&quot;&gt;4get&lt;&#x2F;a&gt; a try, but it seems like it&amp;#39;s not ready for prime time yet. There&amp;#39;s a lot of things that can&amp;#39;t be configured declaratively and needs to be set up using cookies  on the client side through the web UI. And for some reason the Startpage backend didn&amp;#39;t support info widgets like Wikipedia preview. It&amp;#39;s also been similar to SearXNG in terms of memory footprint, so I&amp;#39;d be getting a worse experience for not much resource efficiency.&lt;&#x2F;p&gt;
&lt;p&gt;Very recently I came across &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;git.bwaaa.monster&#x2F;omnisearch&#x2F;about&#x2F;&quot;&gt;OmniSearch&lt;&#x2F;a&gt; (they need better SEO...). While I haven&amp;#39;t tried it yet, it appears promising and I will try setting it up sometime soon and update in a separate post.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;-7&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#-7&quot; aria-label=&quot;Anchor link for: -7&quot;&gt;Files, Photos, Contacts, Calendar&lt;&#x2F;a&gt;&lt;&#x2F;h3&gt;
&lt;p&gt;&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;nextcloud.com&#x2F;&quot;&gt;Nextcloud&lt;&#x2F;a&gt;. Easy, right? Last time when I did it on the same hardware, back in 2020 or 2021, it was fine because I dedicated the whole machine to this one service. Now that I&amp;#39;m trying to diversify my setup, using Nextcloud is difficult on such low RAM. It alone takes between 200-600 MB of RAM (probably more), and has caused the server to freeze at least once. Funny thing is, it happened as I was editing the compose file to limit memory usage. Prophetic. Anyway, added the limits but then it got extremely slow (possibly because it started using swap. I could tell it to not use swap, but... maybe that would lead to other problems? I just did not want to keep optimizing this one thing, so I started looking for alternatives.&lt;&#x2F;p&gt;
&lt;p&gt;For Calendar and Contacts, I did not have to look far. &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;radicale.org&#x2F;v3.html&quot;&gt;Radicle&lt;&#x2F;a&gt; is a lightweight CalDAV and CardDAV server which was trivial to set up. File sync, though, was a different beast...&lt;&#x2F;p&gt;
&lt;p&gt;I tried to set up &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;opencloud.eu&#x2F;en&quot;&gt;OpenCloud&lt;&#x2F;a&gt; but the setup was a showstopper. I wanted something that would work with &lt;em&gt;mostly&lt;&#x2F;em&gt; minimal effort. OpenCloud &lt;em&gt;looked&lt;&#x2F;em&gt; like that&amp;#39;s what it would be, but it was anything but. The &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;opencloud-eu&#x2F;opencloud-compose&quot;&gt;opencloud-compose&lt;&#x2F;a&gt; repository had way too many modules, and used subpar ways to activate the modules. After a few gruelling days of trying to set it up according to docs and debugging the endless stream of errors, I decided to move on.&lt;&#x2F;p&gt;
&lt;p&gt;I dismissed &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;owncloud.com&#x2F;product&quot;&gt;OwnCloud&lt;&#x2F;a&gt; as being no lighter than Nextcloud, and &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;owncloud.com&#x2F;infinite-scale&#x2F;&quot;&gt;OwnCloud Infinite Scale (OCIS)&lt;&#x2F;a&gt; as being no less complex than OpenCloud (due to OpenCloud being based on OCIS).&lt;&#x2F;p&gt;
&lt;p&gt;Was reluctant to try &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;www.seafile.com&#x2F;en&#x2F;home&#x2F;&quot;&gt;Seafile&lt;&#x2F;a&gt; due to the hardware requirements being listed as considerably above what I had. I should probably give it a try sometime. It looks promising, and listed requirements often overestimate in favour of ensuring what the developers consider good UX.&lt;&#x2F;p&gt;
&lt;p&gt;Ended up with &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;cloudreve.org&#x2F;&quot;&gt;Cloudreve&lt;&#x2F;a&gt; for now, using WebDAV-compatible apps for file management and sync. It&amp;#39;s fairly lightweight, and was absolutely trivial to set up. Caveat: the native iOS mobile app used for photos sync is not FOSS. I&amp;#39;ll need to figure out how to sync photos to WebDAV. Or, use a &amp;quot;better&amp;quot; photo backup solution, which is what I &lt;em&gt;tried&lt;&#x2F;em&gt; to opt for.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;immich.app&#x2F;&quot;&gt;Immich&lt;&#x2F;a&gt; seemed to be the most popular option for photo sync. But I recall that on their issue tracker, when encryption at rest was requested to prevent rogue server admins from accessing user photos, or the server being a point of data leak to malicious actors, the official stance was that they will not support encryption for the foreseeable future and since it&amp;#39;s meant to be self-hosted, you would have to trust the server (since it is presumably under your control). To me, this is unacceptable (I mean it makes sense for the project, it just doesn&amp;#39;t suit my needs), so I dismissed Immich.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;ente.io&#x2F;&quot;&gt;Ente&lt;&#x2F;a&gt; felt like a better solution for my needs. I came across it from a post by &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;deobald.ca&#x2F;&quot;&gt;Steven Deobald&lt;&#x2F;a&gt;, an acquaintance from &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;www.halihax.com&#x2F;&quot;&gt;HaliHax&lt;&#x2F;a&gt;, a local dev group. It&amp;#39;s Free and Open-Source Software, is fully self-hostable, and has End-to-End Encryption (E2EE). Fantastic. Except... it uses MinIO (which is now deprecated), and trying to use a different S3-compatible storage backend has been... challenging, to say the least. Last I tried &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;garagehq.deuxfleurs.fr&#x2F;&quot;&gt;Garage&lt;&#x2F;a&gt; but I just couldn&amp;#39;t get everything to work well together. I got uploads to work on the web for a bit, but not on mobile; then it stopped working on web too. For now I am focusing on other things but I intend to get back to it. Hopefully by then there will be official Ente docs and a Docker Compose file for setting up Ente with Garage or some other MinIO alternative.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;-8&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#-8&quot; aria-label=&quot;Anchor link for: -8&quot;&gt;Passphrase Manager&lt;&#x2F;a&gt;&lt;&#x2F;h3&gt;
&lt;blockquote&gt;
&lt;p&gt;For why I call it &amp;quot;passphrase&amp;quot; and not &amp;quot;password&amp;quot;, see the wonderful &lt;code&gt;xkcd#936&lt;&#x2F;code&gt; (linked below).&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;xkcd.com&#x2F;936&#x2F;&quot;&gt;&lt;img src=&quot;https:&#x2F;&#x2F;imgs.xkcd.com&#x2F;comics&#x2F;password_strength.png&quot; title=&quot;Password%20Strength%20%E2%80%94%20xkcd#936&quot; alt=&quot;xkcd#936&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; &#x2F;&gt;&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;bitwarden.com&#x2F;&quot;&gt;Bitwarden&lt;&#x2F;a&gt; seems to be the most popular in this area so I went with that, except on the backend I use &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;dani-garcia&#x2F;vaultwarden&quot;&gt;Vaultwarden&lt;&#x2F;a&gt; because it has some extra features, and more importantly, consumes significantly less resources (from what I&amp;#39;ve read online) due to being (re)written in Rust.&lt;&#x2F;p&gt;
&lt;p&gt;The experience has been great so far. The autofill works well, sync works well, the setup was simple and smooth. Not much to say.&lt;&#x2F;p&gt;
&lt;p&gt;Passphrases, passkeys, and MFA are some of the most important things to secure, so having them self-hosted with tunnelled internet access has been a great relief. I was using Apple Passwords before and now I&amp;#39;m quite happy with Bitwarden&#x2F;Vaultwarden, and I highly recommend it to anyone looking to increase protections for their most important secrets.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;-9&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#-9&quot; aria-label=&quot;Anchor link for: -9&quot;&gt;Git Remote&lt;&#x2F;a&gt;&lt;&#x2F;h3&gt;
&lt;p&gt;&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;forgejo.org&#x2F;&quot;&gt;Forgejo&lt;&#x2F;a&gt; is the standard Git remote frontend most people use. There is also &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;git.zx2c4.com&#x2F;cgit&#x2F;about&#x2F;&quot;&gt;cgit&lt;&#x2F;a&gt; but it&amp;#39;s a bit too barebones for me; I prefer a more GitHub-like experience. Hosting it has given me no issues, but the reason I decided to put it on hold for now is the effort required to move everything from GitHub to Forgejo, the visibility that GitHub provides (which I intend to remedy by setting up mirrors, but again, more effort), and most importantly, the resource limits of my humble hardware. I feel like once I upgrade my hosting computer, I can feel more confident putting more demanding services on it. For now the config is there but commented out (thus deactivated) for my homelab. I did give it a try though, and it worked fine. I&amp;#39;m looking forward to when I can commit to hosting it again.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;-10&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#-10&quot; aria-label=&quot;Anchor link for: -10&quot;&gt;Media Downloader&lt;&#x2F;a&gt;&lt;&#x2F;h3&gt;
&lt;p&gt;&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;imputnet&#x2F;cobalt&quot;&gt;Cobalt&lt;&#x2F;a&gt; is a self-hostable media downloader for sites like Twitter, Reddit, YouTube, etc. Easy to self-host, given the provided Compose file and detailed instructions. Oddly only the backend is self-hostable (for now). The frontend you would use the &amp;quot;official&amp;quot; one and input your backend&amp;#39;s URL in the settings page. I find this setup to be a bit awkward and would&amp;#39;ve preferred hosting my own frontend, but it is what it is; life doesn&amp;#39;t always go our way and that&amp;#39;s okay.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;-11&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#-11&quot; aria-label=&quot;Anchor link for: -11&quot;&gt;Discord Bot&lt;&#x2F;a&gt;&lt;&#x2F;h3&gt;
&lt;p&gt;&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;cybardev&#x2F;cybarbot&quot;&gt;Cy | bot&lt;&#x2F;a&gt; is a Discord bot I made for some simple tasks like sending a message from the bot, searching YouTube videos, creating formatted timestamps, etc. using &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;pycord.dev&#x2F;&quot;&gt;Pycord&lt;&#x2F;a&gt; when I wanted to learn how to make Discord bots. It was a fun and easy process, especially given how good the Pycord documentation is, as well as their helpful community Discord. It&amp;#39;s very easy to self-host too, which is to just run an executable as a service. I containerized it and added it as a Compose file to my homelab, and it has been working great.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;-12&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#-12&quot; aria-label=&quot;Anchor link for: -12&quot;&gt;Monitoring&lt;&#x2F;a&gt;&lt;&#x2F;h3&gt;
&lt;p&gt;At first I thought of using the usual &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;prometheus.io&#x2F;&quot;&gt;Prometheus&lt;&#x2F;a&gt;, &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;grafana.com&#x2F;&quot;&gt;Grafana&lt;&#x2F;a&gt;, etc. stack to learn their usage in a hands-on environment, but after reading online about the hardware requirements, I decided against it. After looking a bit more I came across &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;nicolargo&#x2F;glances&quot;&gt;Glances&lt;&#x2F;a&gt;. Imagine htop but with a web UI — that&amp;#39;s Glances.&lt;&#x2F;p&gt;
&lt;p&gt;There&amp;#39;s a lot of data streams enabled by default which I disabled. I mostly just care about resource usage and alerts if it crosses a threshold, and seeing which programs are causing the high consumption. It&amp;#39;s been a solid experience, being able to monitor my homelab from anywhere without blowing up the hardware.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;-13&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#-13&quot; aria-label=&quot;Anchor link for: -13&quot;&gt;Future&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;Some of the things on my to-do list for the homelab setup are:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;strong&gt;Better hardware&lt;&#x2F;strong&gt;: I want to host more services, more reliably, which would need a more powerful server. Maybe if I get a new main laptop, I&amp;#39;ll use my current M1 MacBook Air as a server. That would also allow me to host LLMs (using something like &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;lmstudio.ai&#x2F;&quot;&gt;LM Studio&lt;&#x2F;a&gt;, unless &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;ollama.com&#x2F;&quot;&gt;Ollama&lt;&#x2F;a&gt; gets &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;ollama&#x2F;ollama&#x2F;issues&#x2F;1730&quot;&gt;MLX support&lt;&#x2F;a&gt; by then), which may be convenient.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;strong&gt;OS&lt;&#x2F;strong&gt;: if I use the MacBook I&amp;#39;ll just use macOS with Docker&#x2F;&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;podman.io&#x2F;&quot;&gt;Podman&lt;&#x2F;a&gt;&#x2F;&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;containerd.io&#x2F;&quot;&gt;containerd&lt;&#x2F;a&gt; on top, but if I get a PC server, I might try something like NixOS, AlmaLinux,  Fedora CoreOS, or even &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;proxmox.com&#x2F;en&#x2F;products&#x2F;proxmox-virtual-environment&#x2F;overview&quot;&gt;Proxmox VE&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;strong&gt;Redundancy&lt;&#x2F;strong&gt;: on better hardware I could also have replicas, especially if I have a multi-server setup or a VPS along with my current server. Even if the services are not redundant, I would at least like the data to be backed up in multiple places. I want to look into Kubernetes too, when I get to the point o increasing the reliability of my server.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;strong&gt;Security&lt;&#x2F;strong&gt;: I should be using full-disk encryption but I currently am not, which means if someone breaks into my room and yanks the homelab (which is just a little 11&amp;quot; laptop) and scrams with it in tow, they can access all the data directly off the SSD since it&amp;#39;s not encrypted at rest. While my threat model is not so high that I am at a high risk of this happening, the chance is always there and it&amp;#39;s best to prepare for such scenarios. I intend to do that, also on better hardware.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;strong&gt;And more&lt;&#x2F;strong&gt;: I am constantly learning, so there may be more things I want to consider changing as my knowledge grows. Stay tuned~&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>Self-hosting a Privacy-focused Search Engine</title>
          <pubDate>Wed, 31 Dec 2025 12:48:00 +0000</pubDate>
          <author>cybardev</author>
          <link>https://cybar.dev/blog/selfhost-searxng/</link>
          <guid>https://cybar.dev/blog/selfhost-searxng/</guid>
          <description xml:base="https://cybar.dev/blog/selfhost-searxng/">&lt;quote-block&gt;
  &lt;blockquote&gt;
  You might not have anything to hide, my friend.&lt;br&gt;But you have everything to protect.
  &lt;&#x2F;blockquote&gt;
  &lt;p&gt;&amp;mdash;&amp;nbsp;&lt;strong&gt;Kevin D. Mitnick&lt;&#x2F;strong&gt;,&amp;nbsp;&lt;cite&gt;The Art of Invisibility&lt;&#x2F;cite&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;quote-block&gt;
&lt;p&gt;It has been over 6 years since I stopped using Google as my default search engine. For a long while I was on Ecosia, and then switched to Brave Search when they launched it. After learning of the active CEO&#x27;s questionable conduct, I dropped Brave (both browser and search) and started using Firefox with Startpage. Of course, I wasn&#x27;t satisfied. Especially after getting a viewport full of ad results one day, I decided I had enough and that it was finally time to self-host a search engine.&lt;&#x2F;p&gt;
&lt;p&gt;Previously I tried making my own search frontend (&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;cybardev&#x2F;search&quot;&gt;github.com&#x2F;cybardev&#x2F;search&lt;&#x2F;a&gt;); while it &quot;worked&quot;, it served a different purpose (mostly as a learning exercise on how APIs work). It wasn&#x27;t much more than a Google search proxy. This time, I needed something more; something more powerful, more feature-rich. Something like... &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;neon-mmd&#x2F;websurfx&quot;&gt;Websurfx&lt;&#x2F;a&gt;?&lt;&#x2F;p&gt;
&lt;p&gt;When it comes to self-hosted web search engines, &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;searxng&#x2F;searxng&quot;&gt;SearXNG&lt;&#x2F;a&gt; is no doubt the standard. However, it&#x27;s a massive piece of software with a lot more features than I need in a program to find links on the web. I wanted something a bit more lightweight, and with a bit of looking around, came across Websurfx. It&#x27;s a metasearch engine like SearXNG, but it&#x27;s a lot more lightweight and focused, which I appreciated. It looked like a perfect match for my use case... until I tried to use it. The setup was straightforward; I even made a home-manager module to configure it using Nix. But no matter what I tried, I could not get it to perform queries consistently. I looked up on their issue tracker, and realized it was a known issue. That in itself should not raise alarms, but the trouble was that looking at the other issues, the commit history, etc. it looked like the project was practically abandoned. I even joined the Discord community to check if there was any activity, or support to make it work, but it was a futile effort. With a sigh I concluded it was time to move on...&lt;&#x2F;p&gt;
&lt;p&gt;SearXNG seemed like the only other option left (feel free to suggest me otherwise). I gave it a trial run in an ephemeral Nix shell and was satisfied with the search experience, so I went ahead and made a &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;cybardev&#x2F;nix-channel&#x2F;blob&#x2F;06247a3c9edb748dc0a27937d53ee19fc143c310&#x2F;mod&#x2F;searxng&#x2F;default.nix&quot;&gt;home-manager module&lt;&#x2F;a&gt; copying some aspects of the NixOS module (but a lot simpler). Did this so I could have the same setup on both Linux (NixOS or otherwise) and Darwin. Over the next month or so I tweaked my SearXNG configuration, only keeping the engines and tabs I care about. I even set up &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;developers.cloudflare.com&#x2F;cloudflare-one&#x2F;networks&#x2F;connectors&#x2F;cloudflare-tunnel&#x2F;&quot;&gt;Cloudflare Tunnel&lt;&#x2F;a&gt; through &lt;code&gt;cloudflared&lt;&#x2F;code&gt; so I can access it over the internet (as long as the laptop is running the service).&lt;&#x2F;p&gt;
&lt;p&gt;A few days ago I thought, it would be nice to host a public instance I can access even when the laptop is off, so I made &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;cybardev&#x2F;searxng-instance&quot;&gt;github.com&#x2F;cybardev&#x2F;searxng-instance&lt;&#x2F;a&gt;. It&#x27;s a set of deployment files, including a Dockerfile that uses the official SearXNG image as base with my configs injected, and a &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;render.com&#x2F;docs&#x2F;infrastructure-as-code&quot;&gt;Render Blueprint&lt;&#x2F;a&gt; (their own IaC — infrastructure as code — solution), allowing one-click deployment of your own instance; simply click on the &quot;Deploy to Render&quot; button in the repository README. I also used &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;render.com&#x2F;docs&#x2F;key-value&quot;&gt;Render Key Value&lt;&#x2F;a&gt; — a Redis-compatible Valkey instance — for cache. Though, due to using a free instance, the actual SearXNG service goes down after a while of unuse. For most people (especially those with a VPS), &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;searxng&#x2F;searxng-docker&quot;&gt;SearXNG&#x27;s Docker Compose files&lt;&#x2F;a&gt; are recommended.&lt;&#x2F;p&gt;
&lt;p&gt;If you&#x27;re privacy-conscious and are looking for an alternative search engine, give SearXNG a try and see how it goes.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>Celebrating My First Nixversary</title>
          <pubDate>Tue, 23 Dec 2025 16:44:00 +0000</pubDate>
          <author>cybardev</author>
          <link>https://cybar.dev/blog/nixversary-1/</link>
          <guid>https://cybar.dev/blog/nixversary-1/</guid>
          <description xml:base="https://cybar.dev/blog/nixversary-1/">&lt;p&gt;Earlier this month I crossed the 1 year mark since I started using Nix in some way or other, and I wanted to take a moment to reflect and appreciate what a positive experience it has been. What started off as a little curiosity has now become a lifeline — a tool that actively boosts my productivity, and allows me to focus on what’s important. It’s also been impactful in helping me understand how my system works, and cutting down unnecessary bloat.&lt;&#x2F;p&gt;
&lt;p&gt;On Linux land, I was used to doing &lt;code&gt;apt install&lt;&#x2F;code&gt; or &lt;code&gt;pacman -Syy&lt;&#x2F;code&gt; commands for package management. Since getting a Mac that changed to &lt;code&gt;brew install&lt;&#x2F;code&gt;, but the flow remained the same — and so did the drawbacks. Run a command, install software, if you don’t use it then forget it exists. The more software you install, the harder it gets to prune. You start hoarding packages like paper rolls during COVID. Mid-to-late 2024 I was looking for ways to lighten up my Mac, after several system warnings about my measly 256GB of storage filling up. Nix promised a solution — declarative configs; you know exactly what’s installed, and installing new programs requires you to type it out so you have time to reconsider if you really need it. I was sold.&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;Here, a little Nix primer may be appropriate for readers unfamiliar with its ecosystem. Nix is not a single software but a variety of interconnected things. There’s Nix the functional programming language, for Nix the declarative package manager, around which NixOS the Linux distribution was built. For macOS there’s Nix-Darwin and community projects like Nix-Homebrew. For user configuration management there’s Home Manager. And to make it more confusing than it already is, there’s two paradigms of package management via Nix — channels and flakes. Flakes use lockfiles to pin versions, while channels does no such thing — you either accept the lack of full reproducibility, or use community-supported version pinning systems like npins. Flake has its own drawbacks, like copying the entire source tree to the Nix Store every time. And yes, Nix Store is another Nix thing; it’s the volume where Nix stores its artifacts (software, configs, etc.), which is different from the Filesystem Hierarchy Standard (FHS) we see in most other forms of package management. Now back to my Nix journey.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;First I wanted to gently test the waters, so I tried installing NixOS on my Surface Laptop (yeah, the first one, which needs a custom kernel built from source for all the components to work under Linux; and this one had a dead SSD and only one USB type-A port so I had to use a dongle to connect the installation drive and the USB drive that&#x27;d act as root; way to test the waters, I know). I could not for the life of me get manual installation to work, at least not through the minimal ISO (did not try with graphical ISO). Downloaded the graphical ISO and booted up Calamares (I later found out I could try manual install through graphical ISO; didn&#x27;t occur to me back then but seems obvious now that I think about it). GUI install went fine and I was on a fresh XFCE installation. Splendid. As I usually do, I swapped out XFWM for BSPWM, since I prefer automatic BSP tiling. Took me some weeks to get it configured exactly how I wanted, with all the software I used. Set up Home Manager, which is a way to manage dotfiles and user services in Nix. And all this I did with the peace of mind that once I have my config ready, I could just run a &lt;code&gt;git clone&lt;&#x2F;code&gt; on my Mac and have it there too (of course I VCS&#x27;d my nixos config; one should always VCS anything they care for). Until now I didn&#x27;t put Nix on my Mac because I had Global Game Jam 2025 coming up and didn&#x27;t want to risk it. Once that was taken care of, it was time to let the floodgates open.&lt;&#x2F;p&gt;
&lt;p&gt;I factory reset my MacBook, after backing up important data, and downloaded Nix. The rest of the year has been an exhilarating blur of learn new aspects of Nix, getting more familiar with the philosophy, engaging with the community, and tweaking my configs. You can see everything that happened in the following two repositories:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;nix-dotfiles&lt;&#x2F;code&gt; (&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;cybardev&#x2F;nix-dotfiles&quot;&gt;github.com&#x2F;cybardev&#x2F;nix-dotfiles&lt;&#x2F;a&gt;): my NixOS and Nix-Darwin configurations&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;nix-channel&lt;&#x2F;code&gt; (&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;cybardev&#x2F;nix-channel&quot;&gt;github.com&#x2F;cybardev&#x2F;nix-channel&lt;&#x2F;a&gt;): my personal package&#x2F;module repository&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;Other than that, here&#x27;s a quick rundown of the highlight of my Nix journey:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Became the maintainer of Meta’s Pyrefly (Python type checker and LSP) package on Nixpkgs.&lt;&#x2F;li&gt;
&lt;li&gt;Made PR (awaiting review) to add and maintain Huggingface’s Git-Xet package.&lt;&#x2F;li&gt;
&lt;li&gt;Crafted a multi-machine, multi-platform config with shared modules.&lt;&#x2F;li&gt;
&lt;li&gt;Maintaining a personal Nix package and module set for stuff I find interesting but don’t quite want to commit to maintaining in upstream Nixpkgs.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;That&#x27;s the gist of it for now. I&#x27;ve been absolutely loving the Nix experience to the point where I don&#x27;t see myself mov away from it anytime soon. If Asahi Linux supported display out over type-C, I&#x27;d love to run full-blown NixOS on my Mac. Till then, Nix-Darwin, Home Manager, and DevShells have me covered.&lt;&#x2F;p&gt;
&lt;p&gt;In later posts I will cover the &quot;tricky&quot; bits of Nix and its ecosystem, such as Flakes, Home Manager, the Module System, DevShells, and more. Stay tuned~&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>My New CMS Setup</title>
          <pubDate>Thu, 04 Dec 2025 15:35:00 +0000</pubDate>
          <author>cybardev</author>
          <link>https://cybar.dev/blog/sveltia-cms-setup/</link>
          <guid>https://cybar.dev/blog/sveltia-cms-setup/</guid>
          <description xml:base="https://cybar.dev/blog/sveltia-cms-setup/">&lt;p&gt;When I was still using &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;gohugo.io&quot;&gt;Hugo&lt;&#x2F;a&gt; for my website, I had set up Netlify CMS (and then moved to &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;decapcms.org&quot;&gt;Decap&lt;&#x2F;a&gt; when they changed the name), thinking it would help me write blogs more smoothly. And sure, the process was less cumbersome than opening up my local repository, firing up a code editor, writing some markdown, and going through the Git flow. But something just didn&#x27;t stick, and I ended up doing that cumbersome process anyway instead of using the CMS. Soon after, I stopped posting altogether. Not surprising.&lt;&#x2F;p&gt;
&lt;p&gt;This year, when I moved my site to &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;www.getzola.org&quot;&gt;Zola&lt;&#x2F;a&gt; with a custom template, I thought I wouldn&#x27;t add a CMS, given my lackluster experience with them in the past. Recently though, I found myself writing (and wanting to write) more and more blog posts. Thanks to that, my flow of writing things in Apple Notes, copy-pasting to code editor, then pushing to Git was getting rather tedious and boring. I was on the lookout for a headless Git-based CMS that would reduce the friction — especially on mobile.&lt;&#x2F;p&gt;
&lt;p&gt;For starters, I went back to Decap. I set it up with a &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;sterlingwes&#x2F;decap-proxy&quot;&gt;Cloudflare Worker OAuth proxy&lt;&#x2F;a&gt; for authentication, so everything remains in my control (at no extra cost). It &quot;worked&quot;, but the mobile experience was as bad as it was the last time I checked (about 2 years ago). I kept looking for a better solution.&lt;&#x2F;p&gt;
&lt;p&gt;Enter &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;sveltia&#x2F;sveltia-cms&quot;&gt;Sveltia CMS&lt;&#x2F;a&gt;. This looked rather promising, but for some reason I was hesitant. That is, until &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;bsky.app&#x2F;profile&#x2F;did:plc:koqqgbhi3dvmcp2jyzfo7x3c&#x2F;post&#x2F;3m6xbitvxa52v&quot;&gt;they tagged me on Bluesky&lt;&#x2F;a&gt; asking me to give it a try. I&#x27;ll be honest, I was initially taken aback by the overeager marketing, but the &quot;Made in Canada 🇨🇦&quot; hook softened me a bit. I looked into it further and decided to give it a try. It was mostly &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;cybardev&#x2F;cybardev.github.io&#x2F;commit&#x2F;47a850404073d6a155488e19ea9084b214450175&quot;&gt;a one line change&lt;&#x2F;a&gt;, with some extra conveniences added on top. I pushed my changes, waited for CI to rebuild and publish, then visited the admin URL. What used to look like an outdated login screen from 2015, now looked… white? I was greeted with a fully blank screen. That&#x27;s not a good sign…&lt;&#x2F;p&gt;
&lt;p&gt;I scurried to the issue tracker for Sveltia, hoping to find a solution, in case I wasn&#x27;t alone. Unfortunately (or maybe it is fortunate that people didn&#x27;t have to deal with it), no one else raised the issue. But before opening an issue, I wanted to confirm that it wasn&#x27;t my fault — that I wasn&#x27;t just using a broken config or something. So I headed to their &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;sveltia&#x2F;sveltia-cms&#x2F;discussions&#x2F;552&quot;&gt;GitHub Discussions&lt;&#x2F;a&gt; and asked what may be causing this blank screen. Within the next 40 minutes, the lead developer of the project had a look, figured out the issue, suggested a solution, and improved on his suggestion. Amazing support.&lt;&#x2F;p&gt;
&lt;p&gt;The issue was Cloudflare&#x27;s Rocket Loader, which I had to disable for the CMS script. Once that was done, I had a beautiful login flow, and elegant CMS interface that looked great on both desktop and mobile. I was thoroughly impressed and satisfied with the switch.&lt;&#x2F;p&gt;
&lt;p&gt;Now, more than ever before, I feel inspired to write on my blog. Thanks Sveltia, for bringing back the joy in writing.&lt;&#x2F;p&gt;
&lt;img src=&quot;https:&#x2F;&#x2F;media.cybar.dev&#x2F;site&#x2F;sveltia-cms-mobile.webp&quot; title=&quot;Sveltia CMS on mobile&quot; alt=&quot;screenshot of Sveltia CMS dashboard showing my blog posts&quot; class=&quot;mobile-ss&quot; &#x2F;&gt;
</description>
      </item>
      <item>
          <title>Hand-coding an SVG Pixel Art</title>
          <pubDate>Tue, 02 Dec 2025 20:42:00 +0000</pubDate>
          <author>cybardev</author>
          <link>https://cybar.dev/blog/coding-svg-pixel-art/</link>
          <guid>https://cybar.dev/blog/coding-svg-pixel-art/</guid>
          <description xml:base="https://cybar.dev/blog/coding-svg-pixel-art/">&lt;p&gt;A few days ago I had the sudden idea of putting up a watermelon &quot;stamp&quot; on a corner of my website (which you may have noticed by now). At first I thought I&#x27;d do a quarter-circle, but then I remembered I already drew a watermelon pixel art before. I wanted to use that but, being the minimalist I am, wanted to have it in a much smaller file size without losing any fidelity. Also didn&#x27;t want to use a low-res image, in case people wanted to zoom in. Thus I concluded that I should recreate the pixel art in vector format (SVG).&lt;&#x2F;p&gt;
&lt;p&gt;Now, SVGs can be made in various software (like Inkscape), but I have found the workflow to be rather cumbersome for pixel art specifically. The snapping to grid is so bad it may not as well be there. I can never get things to align exactly how I want. So, not wanting to deal with that, I chose the option any sane person would (not) — write the SVG code myself.&lt;&#x2F;p&gt;
&lt;p&gt;Thankfully I looked around for a bit before I set off on this arduous task, and came across this &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;TheRealSmeddy&#x2F;svg-pixel-editor&quot;&gt;wonderful project that can be used to create pixel art SVGs&lt;&#x2F;a&gt;. The code is straightforward and they have a static webapp live on GitHub Pages, which is convenient. So I recreated the watermelon there and saved the SVG. Quick and easy. However, the size (~12 KB) was not much smaller than a high-enough resolution export of the raster version of the image (~16 KB). What gives?&lt;&#x2F;p&gt;
&lt;p&gt;It turns out that the webapp, being so simple, included no optimization attempts. So next I set off to look for an SVG optimizer and came across the &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;jakearchibald.github.io&#x2F;svgomg&#x2F;&quot;&gt;SVGOMG website&lt;&#x2F;a&gt;, which is a frontend for the &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;svg&#x2F;svgo&quot;&gt;SVGO command-line utility (and Node module)&lt;&#x2F;a&gt; that does SVG optimization by converting shapes to paths (among other things). It did reduce the file size by a good amount (to ~8 KB), but it was still not enough because of how inefficient the input code was to begin with. Now what?&lt;&#x2F;p&gt;
&lt;p&gt;I thought of combining adjacent squares, but was having trouble visualizing what the optimal combination of rectangles would be. I went on MDN and looked up how SVGs work, to see if there was an easier way. Interestingly, there‘s a section on &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;developer.mozilla.org&#x2F;en-US&#x2F;docs&#x2F;Web&#x2F;SVG&#x2F;Tutorials&#x2F;SVG_from_scratch&quot;&gt;create SVGs from scratch&lt;&#x2F;a&gt;, which was super helpful. From it, I learned how to use the polygon ta and, after brainstorming what the layers would be like, set off on combining the squares into polygons. It was pretty easy but a bit cumbersome having to keep track of the coordinates, how the lines would join up, optimal shape construction, etc. I was using this &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;www.svgplayground.com&#x2F;&quot;&gt;SVG Playground website&lt;&#x2F;a&gt;, which was nice; it has a code editor and image preview pane, which was convenient. I managed to bring down the size to 2.6 KB. This was adequate, so I used SVGOMG to convert it to paths, which more than halved its size to ~900 bytes. Afterwards I added comments to clarify which path was which part&#x2F;layer in the image, which brought up the size to 1.3 KB — still more than good enough for my purposes.&lt;&#x2F;p&gt;
&lt;p&gt;A mistake I made at the start, which made the entire journey harder than it needed to be, was I made the SVG size 20x of the original pixel art. I thought it would make things easier but nope, larger numbers are more difficult to reason about; who would&#x27;ve thunk, eh? I did convert everything down to 20x17 px before the last optimization step though (after I converted everything to polygons). Lesson learned.&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;UPDATE&lt;&#x2F;strong&gt;: I looked into it a bit more and realized, it wasn&#x27;t entirely my fault. The &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;TheRealSmeddy&#x2F;svg-pixel-editor&quot;&gt;SVG pixel art editor&lt;&#x2F;a&gt; I used to generate the initial SVG used 20px squares for each &quot;pixel&quot;. I just didn&#x27;t think of changing it till I was done with the whole process.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;Here&#x27;s the final SVG. I&#x27;m pretty proud of it. 😁&lt;&#x2F;p&gt;
&lt;img src=&quot;&#x2F;assets&#x2F;images&#x2F;watermelon.svg&quot; title=&quot;Bleeding Watermelon&quot; alt=&quot;pixel art of a slice of watermelon with red juice flowing out in a puddle, with a shadow behind the slice&quot;&gt;
</description>
      </item>
      <item>
          <title>How I “Deploy” My Resume</title>
          <pubDate>Sun, 23 Nov 2025 23:20:32 -0400</pubDate>
          <author>cybardev</author>
          <link>https://cybar.dev/blog/resume-deployment/</link>
          <guid>https://cybar.dev/blog/resume-deployment/</guid>
          <description xml:base="https://cybar.dev/blog/resume-deployment/">&lt;p&gt;I briefly went over how I generate my resume in my last blog post &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;cybar.dev&#x2F;blog&#x2F;year-so-far-4-0825&#x2F;#resumake&quot;&gt;Year So Far — Bonus&lt;&#x2F;a&gt;. Here I want to expand on it and describe how I publish my resume on my website for easier sharing.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;what&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#what&quot; aria-label=&quot;Anchor link for: what&quot;&gt;What&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;Recently I switched from a custom resume builder (&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;cybardev&#x2F;resumake&quot;&gt;github.com&#x2F;cybardev&#x2F;resumake&lt;&#x2F;a&gt;) to Typst for building my resume. This allowed me to focus on my resume instead of having to maintain a program&#x2F;module alongside it. After all, the best solutions are the simplest.&lt;&#x2F;p&gt;
&lt;p&gt;With my previous solution, I generated a PDF resume and published it on a GitHub Pages website. I set up a similar (but of course much simpler) workflow for the new Typst resumes. Previously I also had only one resume at a time, but this time I wanted some more flexibility, so now I publish multiple resumes — one for each type of role I target.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;how&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#how&quot; aria-label=&quot;Anchor link for: how&quot;&gt;How&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;I wanted to learn Typst starting from the basics, so instead of using an off-the-shelf Typst resume template, I decided to make my own. It wasn’t that difficult, actually; much easier than it would be with LaTeX, and a lot more manageable than Markdown + CSS. It’s available at &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;cybardev&#x2F;resume-template-typst&quot;&gt;github.com&#x2F;cybardev&#x2F;resume-template-typst&lt;&#x2F;a&gt; with an MIT license. There’s a function for each element, like header, project, experience, education, etc. and they can be organized into sections easily with some basic Typst. There’s a helper function to compose the whole resume, but it has a specific layout that not everyone might like.&lt;&#x2F;p&gt;
&lt;p&gt;After writing my resume using the above template, I set up my editors to automatically generate PDF previews on save, and for a while I used the PDFs generated this way for job applications. That was fine, but I still wanted to have a public link I could share around and put on my social profiles. So, I set out to create a GitHub Actions workflow to deploy it to a GitHub Pages website, like how its predecessor Resumake had. You can see the workflow file by clicking &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;cybardev&#x2F;resume-template-typst&#x2F;blob&#x2F;main&#x2F;.github&#x2F;workflows&#x2F;publish.yml&quot;&gt;this link&lt;&#x2F;a&gt;. It generates a resume from each &lt;code&gt;*.typ&lt;&#x2F;code&gt; file in the &lt;code&gt;src&#x2F;&lt;&#x2F;code&gt; directory with a filename like &lt;code&gt;Resume_Sheikh_Saad_Abdullah_(${1}).pdf&lt;&#x2F;code&gt; where &lt;code&gt;${1}&lt;&#x2F;code&gt; is the basename of the &lt;code&gt;.typ&lt;&#x2F;code&gt; file.&lt;&#x2F;p&gt;
&lt;p&gt;There’s yet another layer to this. My DNS is set up to publish this GitHub Pages site on &lt;code&gt;resume.cybar.dev&lt;&#x2F;code&gt;, so my resumes would be available like &lt;code&gt;resume.cybar.dev&#x2F;Resume_Sheikh_Saad_Abdullah_(${1}).pdf&lt;&#x2F;code&gt;. No one is going to type all that. So I set up URI redirect rules in Cloudflare so when people go to &lt;code&gt;resume.cybar.dev&#x2F;devops&#x2F;&lt;&#x2F;code&gt;, it expands to &lt;code&gt;resume.cybar.dev&#x2F;Resume_Sheikh_Saad_Abdullah_(devops).pdf&lt;&#x2F;code&gt;, and so on.&lt;&#x2F;p&gt;
&lt;p&gt;Something to note is that the trailing slash is necessary, i.e. &lt;code&gt;resume.cybar.dev&#x2F;devops&#x2F;&lt;&#x2F;code&gt; works but &lt;code&gt;resume.cybar.dev&#x2F;devops&lt;&#x2F;code&gt; does not. This is because without the slash, Cloudflare would have to interpret it as a file and attempt to redirect the URI to another file (the PDF), but then that file would also cause a redirect, leading to infinite recursion. This is because I am on the Cloudflare Free plan which only supports wildcard matching; Business and Enterprise plans have access to regex matching, which would allow capturing URI with paths not ending in &lt;code&gt;.pdf&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;UPDATE&lt;&#x2F;strong&gt;: The trailing slash is no longer necessary. I restructured the generated site so &lt;code&gt;resume.cybar.dev&#x2F;*&#x2F;&lt;&#x2F;code&gt; paths are directories with the generated PDF, and an &lt;code&gt;index.html&lt;&#x2F;code&gt; that redirects to the PDF. It uses the &lt;code&gt;&amp;lt;meta http-equiv=&quot;refresh&quot;&amp;gt;&lt;&#x2F;code&gt; tag to achieve this. You can see how it works in &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;cybardev&#x2F;resume&#x2F;blob&#x2F;main&#x2F;.github&#x2F;workflows&#x2F;publish.yml&quot;&gt;the GitHub Actions workflow file&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;NOTE&lt;&#x2F;strong&gt;: You might’ve noticed that the &lt;code&gt;resume&lt;&#x2F;code&gt; repo is older than the template repo. That’s cuz I didn’t think of making the Typst resume module a template. At the time I was making it for myself and didn’t think of starting with a template first, then implementing it for my own resume. Oopsie~ :3&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;h2 id=&quot;why&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#why&quot; aria-label=&quot;Anchor link for: why&quot;&gt;Why&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;At this point you might be wondering, why would anyone even want to go through all this effort just to get some resumes out? A similar effect can be achieved with something like MS Word for resume creation and Google Drive for storing and sharing.&lt;&#x2F;p&gt;
&lt;p&gt;The issue with most rich text editors is that they add a lot of unnecessary metadata to PDF exports, which may confuse ATS resume parsers. It’s not a certainty but from what I’ve gathered, it’s safer to generate PDFs programmatically via LaTeX or such. Also, I find it a much nicer flow to edit my resume in Helix editor in the terminal; the shortcuts and motions are very useful. That, and being able to have a plaintext source file to track cleanly in Git adds to the convenience.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;conclusion&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#conclusion&quot; aria-label=&quot;Anchor link for: conclusion&quot;&gt;Conclusion&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;If you’re already familiar with LaTeX and want to make resume generation easier, there’s services like &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;www.overleaf.com&quot;&gt;Overleaf&lt;&#x2F;a&gt; that can reduce the pain. If the Typst resume flow catches your fancy, feel free to check out and use &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;cybardev&#x2F;resume-template-typst&quot;&gt;my template repository&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;And, if you’re looking for a developer who can get things done, here’s my resume: &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;resume.cybar.dev&#x2F;devops&#x2F;&quot;&gt;resume.cybar.dev&#x2F;devops&#x2F;&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>Year So Far — Bonus</title>
          <pubDate>Sun, 10 Aug 2025 17:00:00 -0300</pubDate>
          <author>cybardev</author>
          <link>https://cybar.dev/blog/year-so-far-4-0825/</link>
          <guid>https://cybar.dev/blog/year-so-far-4-0825/</guid>
          <description xml:base="https://cybar.dev/blog/year-so-far-4-0825/">&lt;h2 id=&quot;what-s-this-about&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#what-s-this-about&quot; aria-label=&quot;Anchor link for: what-s-this-about&quot;&gt;What’s this about?&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;Oftentimes I get so immersed in what I do, one thing after the other, I forget to take a step back and notice what I’ve accomplished. It’s important to do this from time to time, so when I feel down about not doing enough in moments of downtime, I have something to look at and go, “No, I am doing my best.”&lt;&#x2F;p&gt;
&lt;p&gt;This is one such list, for what I’ve been up to this year till now. Here’s a glimpse into the life of Sheikh, halfway through 2025.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;the-list-continued&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#the-list-continued&quot; aria-label=&quot;Anchor link for: the-list-continued&quot;&gt;The List, continued...&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;&lt;em&gt;[Bonus Part]&lt;&#x2F;em&gt;&lt;&#x2F;p&gt;
&lt;h2 id=&quot;honourable-mentions&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#honourable-mentions&quot; aria-label=&quot;Anchor link for: honourable-mentions&quot;&gt;Honourable Mentions&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;Here are some things I did this year, but either don’t have a lot to talk about, or have moved on from. Regardless, the experiences I got from working on them have become a part of me, and I learned a lot, so I wanted to at least mention them.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;habitmap&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#habitmap&quot; aria-label=&quot;Anchor link for: habitmap&quot;&gt;HabitMap&lt;&#x2F;a&gt;&lt;&#x2F;h3&gt;
&lt;p&gt;Wanted to make a habit tracker app with a heatmap calendar similar to the GitHub commit chart. Started making it in Flutter because I wanted to learn it, and I did make some good progress. A few weeks in though, I came to know about &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;www.habitkit.app&#x2F;&quot;&gt;HabitKit&lt;&#x2F;a&gt; from a YouTube video. It looked like exactly what I wanted, so I stopped working on my project in favour of it. It wasn’t a waste though, as now I have some exposure to Flutter and understand the basics of how it works.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;resumake&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#resumake&quot; aria-label=&quot;Anchor link for: resumake&quot;&gt;Resumake&lt;&#x2F;a&gt;&lt;&#x2F;h3&gt;
&lt;p&gt;A long-running project that has served me well. It was a resume generator, first made in Python, and later translated to Go, containerized, published using GitHub Actions CI&#x2F;CD workflow. Learned a lot making it, and got to use it for over 2 years to make my resumes, getting me two co-ops and a part-time job. Recently though, I got to know about &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;typst.app&#x2F;&quot;&gt;Typst&lt;&#x2F;a&gt; — a LaTeX alternative that actually makes sense. The syntax lies somewhere between LaTeX and Markdown, so it’s the perfect mix of ease and power. Using it going forward for writing my resumes, cover letters, and any other PDF documents.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;learning-opentofu-terraform-from-the-linux-foundation&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#learning-opentofu-terraform-from-the-linux-foundation&quot; aria-label=&quot;Anchor link for: learning-opentofu-terraform-from-the-linux-foundation&quot;&gt;Learning OpenTofu&#x2F;Terraform from The Linux Foundation&lt;&#x2F;a&gt;&lt;&#x2F;h3&gt;
&lt;p&gt;I’m quite interested in DevOps, SRE, Platform Engineering, etc. and one major aspect of it is managing infrastructure as code through technologies like Terraform. It’s always been sort of a “black box” to me; I understood what it did and what it’s used for, but wasn’t sure how to get started with it. While looking up resources on it, I came across this certificate program from The Linux Foundation on OpenTofu — the Free and Open-source fork of Terraform. Best part? It’s free and takes only an hour. Did that, then took the exam while waiting for the bus. The course content was pretty nice and clear. Concise, but covering all the important points. Really helped me demystify the technology, and I was able to implement it for a real project (the Graphite image editor, mentioned a bit below). Definitely recommend the course if anyone else wants a quick start guide for Terraform&#x2F;OpenTofu: &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;training.linuxfoundation.org&#x2F;express-learning&#x2F;getting-started-with-opentofu-lfel1009&#x2F;&quot;&gt;Getting Started with OpenTofu (LFEL1009) — The Linux Foundation&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3 id=&quot;packaging-meta-s-pyrefly-in-a-homebrew-tap&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#packaging-meta-s-pyrefly-in-a-homebrew-tap&quot; aria-label=&quot;Anchor link for: packaging-meta-s-pyrefly-in-a-homebrew-tap&quot;&gt;Packaging Meta’s Pyrefly in a Homebrew Tap&lt;&#x2F;a&gt;&lt;&#x2F;h3&gt;
&lt;p&gt;Similar to the nixpkgs, I wanted to learn how to package software for &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;brew.sh&quot;&gt;Homebrew&lt;&#x2F;a&gt; — a package manager (previously for macOS, but it’s available on Linux too now). Since I already had experience packaging Pyrefly, I thought this would be a nice complement. Followed the official documentation and ended up making this “Tap”, which is basically just a personal package repository for Homebrew: &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;cybardev&#x2F;homebrew-tap&quot;&gt;https:&#x2F;&#x2F;github.com&#x2F;cybardev&#x2F;homebrew-tap&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3 id=&quot;deploy-personal-instance-of-graphite&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#deploy-personal-instance-of-graphite&quot; aria-label=&quot;Anchor link for: deploy-personal-instance-of-graphite&quot;&gt;Deploy Personal Instance of Graphite&lt;&#x2F;a&gt;&lt;&#x2F;h3&gt;
&lt;p&gt;&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;GraphiteEditor&#x2F;Graphite&quot;&gt;Graphite&lt;&#x2F;a&gt; is a fantastic Free and Open-source graphic editor that handles &lt;em&gt;both&lt;&#x2F;em&gt; raster and vector graphics. I now prefer it over GIMP and Inkscape. It’s still in its early days, but already usable for all my needs. It is a webapp, so it doesn’t need to be installed locally, but it’s static, so all the processing is done client-side (even restoring previous sessions work using browser cache) — no account needed. Had to deploy it somewhere, so I chose Render. Tried to use OpenTofu and almost got it working, but then was hit with “you need a paid Render subscription” for Terraform deployments, so I just used Render Blueprint — their own infrastructure-as-code (IaC) solution, which is available on free tier too. It’s up now at &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;gfx.cybar.dev&quot;&gt;gfx.cybar.dev&lt;&#x2F;a&gt; (cold start, so probably have to wait a bit).&lt;&#x2F;p&gt;
&lt;h3 id=&quot;halihax-collect-side-projects-meetup&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#halihax-collect-side-projects-meetup&quot; aria-label=&quot;Anchor link for: halihax-collect-side-projects-meetup&quot;&gt;HaliHax&#x2F;Collect. Side Projects Meetup&lt;&#x2F;a&gt;&lt;&#x2F;h3&gt;
&lt;p&gt;Every Monday evening I meet up with folks from a local developer group called &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;www.halihax.com&#x2F;&quot;&gt;HaliHax&lt;&#x2F;a&gt; for a few hours of coding. Think of it like &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;en.m.wikipedia.org&#x2F;wiki&#x2F;Parallel_play&quot;&gt;“parallel play”&lt;&#x2F;a&gt; but for adults coding. This kind of environment helps me focus and provides a sense of accountability; really nice to get work done, be it serious stuff, or just some new exploration. Sandy Walsh is the host, but usually takes a break from it every summer. I still wanted to continue, so every Monday I ping the channel to gather anyone who’s interested. We meet at the same bar and get cracking. Recently, the side-projects event series has rebranded to be a part of the &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;www.collecthalifax.org&#x2F;&quot;&gt;Collect. community&lt;&#x2F;a&gt;, which is nice. Now it’s called Collect. Mondays.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;strong&gt;Bonus&lt;&#x2F;strong&gt;: My friend Naziya drew a gorgeous banner for Collect. Monday events:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;media.cybar.dev&#x2F;site&#x2F;collect-banner.png&quot; alt=&quot;Collect. Banner&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;h3 id=&quot;&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#&quot; aria-label=&quot;Anchor link for: &quot;&gt;Miscellaneous&lt;&#x2F;a&gt;&lt;&#x2F;h3&gt;
&lt;p&gt;Something major I did near the start of the year is started using Nix for package management, configuration management, locally running services, and development environments. It has been a life changing experience, but I want to dive deeper into it, so I’ll leave it for another blog post.&lt;&#x2F;p&gt;
&lt;p&gt;Another thing I want to do is to switch to a locally hosted VCS server. Initially I was thinking &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;forgejo.org&#x2F;&quot;&gt;Forgejo&lt;&#x2F;a&gt; but someone introduced me to &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;charmbracelet&#x2F;soft-serve&quot;&gt;soft-serve&lt;&#x2F;a&gt; and I might give that a try instead. I already started using Forgejo a little, but haven&amp;#39;t moved anything over. Eventually I want everything primarily local, with repositories mirrored on GitHub.&lt;&#x2F;p&gt;
&lt;p&gt;Also changed the following tools and technologies:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;GUI editor: VS Code (Codium) —&amp;gt; Zed&lt;&#x2F;li&gt;
&lt;li&gt;TUI editor: Neovim —&amp;gt; Helix (evil-helix)&lt;&#x2F;li&gt;
&lt;li&gt;Git client: gitui —&amp;gt; lazygit&lt;&#x2F;li&gt;
&lt;li&gt;File Manager: yazi —&amp;gt; lf&lt;&#x2F;li&gt;
&lt;li&gt;Shell: zsh —&amp;gt; fish&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;Reasons:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Zed &lt;em&gt;feels&lt;&#x2F;em&gt; snappier, and more within my control. Also isn&amp;#39;t Electron bloat. Still keeping VS Code (Codium) around for backup though, and some more &amp;quot;involved&amp;quot; projects, especially if I work with people who use VS Code.&lt;&#x2F;li&gt;
&lt;li&gt;Helix comes with sane defaults and doesn&amp;#39;t need a minimum of 300+ lines for a usable setup.&lt;&#x2F;li&gt;
&lt;li&gt;Lazygit has interactive rebase, and there&amp;#39;s more information in one UI instead of being split over multiple tabs (just my preference; some may prefer the sparse layout of gitui).&lt;&#x2F;li&gt;
&lt;li&gt;Yazi was becoming a pain. Too active development, too many breaking changes too often, and tries to do more than I need it for. It feels like it&amp;#39;s trying to provide sane defaults like Helix, but it&amp;#39;s not nice if the &amp;quot;defaults&amp;quot; change every other week. Lf, though more barebones, is much more stable, and mostly does what I want. I can tolerate it for now, at least until Yazi stops moving so fast.&lt;&#x2F;li&gt;
&lt;li&gt;I used to use fish before zsh, and now I&amp;#39;m back again. It&amp;#39;s just more ergonomic for interactive use, and there&amp;#39;s a lot more builtin features that I used plugins for in zsh. Zsh is still my system shell; fish is only used in the kitty terminal and the integrated terminal in GUI editors.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h2 id=&quot;-1&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#-1&quot; aria-label=&quot;Anchor link for: -1&quot;&gt;And More to Come…&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;That’s all for what I did so far. As for what’s next…&lt;&#x2F;p&gt;
&lt;p&gt;I’m currently learning Rust, to try to understand what has made it “the most loved language” for about a decade (&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;survey.stackoverflow.co&#x2F;2025&#x2F;technology#admired-and-desired-language-desire-admire&quot;&gt;StackOverflow Developer Survey&lt;&#x2F;a&gt;). Might do a project, or translate one of my older ones. If I like it, I’d like to try making some FOSS contributions with it.&lt;&#x2F;p&gt;
&lt;p&gt;I’ve also been learning Go (the board game now; I’m already a bit familiar with the language). The interest arose after having seen it in a few wuxia manhuas (Chinese comics of the martial fantasy genre). It’s a really deep and fascinating game, whose simple rules hide a much more complex story. While it’s been more frustrating than fun (due to skill issue) so far, I’m looking forward to diving deeper into this super-interesting ancient strategy game that’s survived for millennia.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;strong&gt;Bonus&lt;&#x2F;strong&gt;: A friend of mine (Naziya, the one with the beautiful art) suggested the anime (Japanese animation) Hikaru no Go, which is all about the board game and apparently helpful for learning some of the foundations. Will hopefully watch it throughout this September.&lt;&#x2F;p&gt;
&lt;p&gt;Sometime soon I’ll get back to my Game Jam game and make a release for Bubble Blaster DX. Just need to polish the existing mechanics and see how I can add to the gameplay experience without diverging from the original vision.&lt;&#x2F;p&gt;
&lt;p&gt;With this series, I’m trying to get back to blogging, so will try to post every now and then. Writing down ideas helps consolidate learning, so looking forward to it. Hope you all enjoy reading these as much as I do writing. If you have any questions, ideas, suggestions, or just want to chat, feel free to reach out on my LinkedIn (&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;www.linkedin.com&#x2F;in&#x2F;cybardev&quot;&gt;linkedin.com&#x2F;in&#x2F;cybardev&lt;&#x2F;a&gt;) or send me an email at &lt;a href=&quot;mailto:sheikh@cybar.dev&quot;&gt;sheikh@cybar.dev&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;&lt;strong&gt;And, having graduated, I am now on the lookout for a new role. If you or anyone you know is looking for an ever-growing and curious soul who loves learning, exploring, and solving problems, let’s connect — I’d love to hear from you.&lt;&#x2F;strong&gt;&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>Year So Far — Part 3</title>
          <pubDate>Sun, 03 Aug 2025 19:48:00 -0300</pubDate>
          <author>cybardev</author>
          <link>https://cybar.dev/blog/year-so-far-3-0825/</link>
          <guid>https://cybar.dev/blog/year-so-far-3-0825/</guid>
          <description xml:base="https://cybar.dev/blog/year-so-far-3-0825/">&lt;h2 id=&quot;what-s-this-about&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#what-s-this-about&quot; aria-label=&quot;Anchor link for: what-s-this-about&quot;&gt;What’s this about?&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;Oftentimes I get so immersed in what I do, one thing after the other, I forget to take a step back and notice what I’ve accomplished. It’s important to do this from time to time, so when I feel down about not doing enough in moments of downtime, I have something to look at and go, “No, I am doing my best.”&lt;&#x2F;p&gt;
&lt;p&gt;This is one such list, for what I’ve been up to this year till now. Here’s a glimpse into the life of Sheikh, halfway through 2025.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;the-list-continued&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#the-list-continued&quot; aria-label=&quot;Anchor link for: the-list-continued&quot;&gt;The List, continued...&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;&lt;em&gt;[Part 3 of 3]&lt;&#x2F;em&gt;&lt;&#x2F;p&gt;
&lt;h3 id=&quot;packaging-meta-s-pyrefly-for-nixpkgs&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#packaging-meta-s-pyrefly-for-nixpkgs&quot; aria-label=&quot;Anchor link for: packaging-meta-s-pyrefly-for-nixpkgs&quot;&gt;Packaging Meta’s Pyrefly for Nixpkgs&lt;&#x2F;a&gt;&lt;&#x2F;h3&gt;
&lt;p&gt;End of May I came across &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;engineering.fb.com&#x2F;2025&#x2F;05&#x2F;15&#x2F;developer-tools&#x2F;introducing-pyrefly-a-new-type-checker-and-ide-experience-for-python&#x2F;&quot;&gt;Meta’s new Python type checker and LSP — Pyrefly&lt;&#x2F;a&gt;. By now I’ve been deep down the Nix rabbit hole, and realized there’s no Pyrefly package on nixpkgs, so if I wanted to use it through Nix, I’d have to package it myself. After making a package request issue on nixpkgs thinking that it was beyond my skills (having zero Rust experience), I suddenly felt adventurous and started working on it anyway, making a draft PR. With substantial help from the wonderful community on the (unofficial) Nix&#x2F;OS Discord, I made significant progress. Then suddenly someone in the Discord said they have been using a custom package for a while, and theirs looked cleaner than what I had. So we chatted and agreed to co-author and co-maintain the package. I opened the PR (&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;NixOS&#x2F;nixpkgs&#x2F;pull&#x2F;412863&quot;&gt;NixOS&#x2F;nixpkgs#412863&lt;&#x2F;a&gt;) and, after some code review and improvements, it got merged. This was my biggest PR so far, and first time contributing to such a large open source project used by thousands of people. I learned a lot from this experience; most notably, &lt;code&gt;git rebase --interactive&lt;&#x2F;code&gt;, mainly relying on this wonderful Atlassian article: &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;www.atlassian.com&#x2F;git&#x2F;tutorials&#x2F;rewriting-history&#x2F;git-rebase&quot;&gt;git rebase | Atlassian Git Tutorial&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;I also got the chance to speak with the Pyrefly team on Discord, and they were very helpful and cooperative during the packaging process. The tool has been working out great for me so far, but it&#x27;s still alpha software, so there&#x27;s a lot more to come; most notably, the LSP server is lacking a few features, and they rely on rust nightly, which is a big no-no for packaging for both nixpkgs and homebrew. We had to use a hacky workaround, setting the environment variable &lt;code&gt;RUSTC_BOOTSTRAP&lt;&#x2F;code&gt; to &lt;code&gt;1&lt;&#x2F;code&gt; to get it to work on stable rust. They&#x27;re working on it though, so hopefully it&#x27;ll be ready soon. One of the team members also sent me some cool Pyrefly merch, (stickers and screen wipe pictured below, and a t-shirt of my size they asked by email), so that was really cool. Perks of contributing to open source.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;media.cybar.dev&#x2F;site&#x2F;pyrefly-merch.jpg&quot; alt=&quot;pyrefly merch&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;h3 id=&quot;&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#&quot; aria-label=&quot;Anchor link for: &quot;&gt;ShiftKey Algorithms and Leetcode&lt;&#x2F;a&gt;&lt;&#x2F;h3&gt;
&lt;p&gt;Once a week through June, I attended the Intro to Algorithmic Problem Solving course by ShiftKey at Dalhousie. It was taught by Yuhan Fu, an MCS Graduate from Dalhousie and also a TA there. She also has experience in research on Optimization Algorithms, participated and won multiple hackathons, and volunteering as a full-stack developer. On another side, she runs a K-pop dance cover team and teaches K-pop dance classes. With such a multi-talented teacher at the helm, classes were bound to be interesting. Topics we went through included Fundamental Data Structures and Complexity Analysis, Sorting and Recursion, Searching and Graphs, and Greedy and Dynamic Programming. I honestly learned a lot. Got (somewhat) over my distaste of Leetcode. Had fun with solving problems, and finally understood why so many people live by it. It is, however, not my path, since I got so burnt out by the end of it, I ended up not taking the exam, so I didn’t get the certificate from this course. This is the farthest I have gotten with algorithms though, so big respect to Yuhan and ShiftKey for helping me get through it.&lt;&#x2F;p&gt;
&lt;p&gt;I wish Leetcode questions focused more on realistic scenarios instead of fantasy situations. For me, it is difficult to feel interested in things I don’t see the point of, especially if that thing requires high mental effort. I recently did a coding assessment for a company where the questions were similar to actual work one would do. One question required me to parse a Google Doc from a given URL and perform data manipulation operations on an embedded table using the &lt;code&gt;pandas&lt;&#x2F;code&gt; Python library, then printing human-readable information to standard output. If DSA is so crucial for jobs, they should design questions that give us a glimpse of how these DSA could be used at work.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;-1&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#-1&quot; aria-label=&quot;Anchor link for: -1&quot;&gt;Personal Website with semantic HTML&lt;&#x2F;a&gt;&lt;&#x2F;h3&gt;
&lt;p&gt;End of June, I decided to remake my website. Previously I was using a pre-made template for Hugo, but the template has been unmaintained since 2021. I wanted to make my site using pure HTML&#x2F;CSS as much as possible, ensuring full functionality even with JavaScript disabled. I did that, and learned a lot about CSS animations, media queries, and used semantic HTML for the structure. At first I thought to just not have a blog on there, but while going through the other websites in the web ring I joined (&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;nixwebr.ing&quot;&gt;nixwebr.ing&lt;&#x2F;a&gt;), I came across Zola, which is a much more minimal static site generator than Hugo, so I reconsidered using it to add back the blog. Did that (&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;cybar.dev&#x2F;blog&#x2F;&quot;&gt;cybar.dev&#x2F;blog&lt;&#x2F;a&gt;, which you are now reading), and as a bonus added a gallery section too (&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;cybar.dev&#x2F;gallery&#x2F;&quot;&gt;cybar.dev&#x2F;gallery&lt;&#x2F;a&gt;); it now shows some of my favourite artwork (pixel art) right on my website. It wasn’t much work to break up the HTML file to match the Zola template structure, and ultimately the served files are still just HTML and CSS for the most part. JS is only used to detect and store dark&#x2F;light theme preference. Overall, I’m quite satisfied with how it turned out. I especially like the breathing “bar” on the homepage; even use it to time breathing exercises sometimes, which is fun.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>Year So Far — Part 2</title>
          <pubDate>Sat, 19 Jul 2025 13:48:00 -0300</pubDate>
          <author>cybardev</author>
          <link>https://cybar.dev/blog/year-so-far-2-0725/</link>
          <guid>https://cybar.dev/blog/year-so-far-2-0725/</guid>
          <description xml:base="https://cybar.dev/blog/year-so-far-2-0725/">&lt;h2 id=&quot;what-s-this-about&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#what-s-this-about&quot; aria-label=&quot;Anchor link for: what-s-this-about&quot;&gt;What’s this about?&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;Oftentimes I get so immersed in what I do, one thing after the other, I forget to take a step back and notice what I’ve accomplished. It’s important to do this from time to time, so when I feel down about not doing enough in moments of downtime, I have something to look at and go, “No, I am doing my best.”&lt;&#x2F;p&gt;
&lt;p&gt;This is one such list, for what I’ve been up to this year till now. Here’s a glimpse into the life of Sheikh, halfway through 2025.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;the-list-continued&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#the-list-continued&quot; aria-label=&quot;Anchor link for: the-list-continued&quot;&gt;The List, continued...&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;&lt;em&gt;[Part 2 of 3]&lt;&#x2F;em&gt;&lt;&#x2F;p&gt;
&lt;h3 id=&quot;digital-nova-scotia-skills-for-hire-cybersecurity&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#digital-nova-scotia-skills-for-hire-cybersecurity&quot; aria-label=&quot;Anchor link for: digital-nova-scotia-skills-for-hire-cybersecurity&quot;&gt;Digital Nova Scotia — Skills For Hire: Cybersecurity&lt;&#x2F;a&gt;&lt;&#x2F;h3&gt;
&lt;p&gt;February I started a 16-week Cybersecurity course with Skills for Hire by Digital Nova Scotia. It was with this course that the ShiftKey course had a lot of overlap with, but that meant I could use one to consolidate the other. We had Pluralsight videos, weekly TA sessions, assignments, and career development webinars, all of which were super helpful.&lt;&#x2F;p&gt;
&lt;p&gt;The Pluralsight videos helped me understand a lot better how computer networking works, and what their weaknesses could be, as well as how to cover them. I also learned about risk management — since it’s impossible (or at least not feasible) to perfectly secure all aspects of a system, it makes sense to prioritize mitigating certain risks while accepting others and planning to work around them. I liked that there were a ton of hands-on components that I could try out, like log file analysis, cryptography, network monitoring, etc.&lt;&#x2F;p&gt;
&lt;p&gt;The program included a waiver for the ISC2 membership fees if we passed the ISC2 CC exam at the end of the course. More on that in a bit.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;convocation-ceremony&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#convocation-ceremony&quot; aria-label=&quot;Anchor link for: convocation-ceremony&quot;&gt;Convocation Ceremony&lt;&#x2F;a&gt;&lt;&#x2F;h3&gt;
&lt;p&gt;In May, SMU held the convocation ceremony for Jan 2025 graduates. I have always had little interest and faith in formal education, especially in the memorization-favouring system that we currently have, which was created to produce uniform-minded factory workers and not creative individuals prepared for modern society. And all that at the cost of my parents’ hard-earned money and my fleeting sanity. I find the whole ordeal utterly ridiculous and a prime waste of resources. I would not, had we a more favourable world for humans, but alas that is not the world we live in. Regardless, I graduated, and hopefully made my parents happy. That’s all that matters to me for this chapter.&lt;&#x2F;p&gt;
&lt;p&gt;It was definitely an interesting experience going up on stage and receiving the roll of paper that validated the four and some years of learning I just completed. Got some nice pictures taken, spent time with friends. I wish my parents could attend though; this was for them, after all.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;media.cybar.dev&#x2F;site&#x2F;convocation.jpg&quot; alt=&quot;convocation photo&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;PS&lt;&#x2F;em&gt;&lt;&#x2F;strong&gt;&lt;em&gt;: I don’t dislike university, in fact I believe all stages of education should have the level of freedom and agency that university gives us (and that universities should have &lt;strong&gt;more&lt;&#x2F;strong&gt; freedom, especially in letting us ditch unrelated electives). However I am an avid hater of mid-term and final exams. I am largely in favour of intermittent testing and practical assessments.&lt;&#x2F;em&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Just thought I should clarify. Moving on…&lt;&#x2F;p&gt;
&lt;h3 id=&quot;&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#&quot; aria-label=&quot;Anchor link for: &quot;&gt;ISC2 CC Certification Exam&lt;&#x2F;a&gt;&lt;&#x2F;h3&gt;
&lt;p&gt;Second week of June, I sat for the ISC2 CC exam. ISC2, or International Information System Security Certification Consortium (you can see why I’ve been abbreviating it thus far and will continue going forward), is one of the world’s leading training organizations in the field of cybersecurity. The “Certified in Cybersecurity” (CC) certificate is their entry-level offering, which they’ve been giving away for quite a while now. The catch is that after you pass you have to pay the annual membership fee of 50 CAD, which is still &lt;em&gt;way&lt;&#x2F;em&gt; less than any other entry-level cybersecurity certifications that are worth doing (looking at you, CompTIA and Cisco).&lt;&#x2F;p&gt;
&lt;p&gt;The 4-month training from DNS Skills for Hire, as well as the ShiftKey Cybersecurity course, were greatly helpful for this exam. Thanks to those I barely had to study. I wanted to, but I only took one practice exam and barely passed that, then procrastinated till there was no time left to study. Then I just said Bismillah (in the name of Allah; Muslims say this before starting things) and went on to wing it.&lt;&#x2F;p&gt;
&lt;p&gt;It was fun, cuz the morning of exam day I got a call which woke me up, from the testing centre, saying someone cancelled their morning slot so I can come in earlier if I wanted to. I thought I might as well get it over with, since I don’t believe in studying right before exams (if I touch it, I will only recall what I just read and nothing else, which is why I’d rather not and keep it all equalized). Went to the place and the test was so intuitively easy, (likely thanks to the training&#x2F;courses), I finished the 120 minute exam with 95 minutes remaining. I was afraid, though, since there were quite a few questions I just guessed the answer to; but I don’t like dwelling on a problem to boil my brain over something I may or may not know, so I just take a guess and move on to the next question.&lt;&#x2F;p&gt;
&lt;p&gt;After the test, the examiner handed me a paper saying I passed. I was pleasantly surprised cuz of how fast the evaluation was. I shouldn’t be, because it’s just MCQ with known answers, but it’s not as common as it should be. A few days later I got the official certificate online, which you can see here: &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;www.credly.com&#x2F;badges&#x2F;dd205943-5edf-4284-ab13-3dedf144668f&quot;&gt;ISC2 CC — Credly Badge&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;I don’t know what industry value this certificate holds, but I learned a lot — about IT, Networking, Cybersecurity, and more — in the process of getting it, so I consider this a great success.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>Year So Far — Part 1</title>
          <pubDate>Mon, 14 Jul 2025 11:20:00 -0300</pubDate>
          <author>cybardev</author>
          <link>https://cybar.dev/blog/year-so-far-1-0725/</link>
          <guid>https://cybar.dev/blog/year-so-far-1-0725/</guid>
          <description xml:base="https://cybar.dev/blog/year-so-far-1-0725/">&lt;h2 id=&quot;what-s-this-about&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#what-s-this-about&quot; aria-label=&quot;Anchor link for: what-s-this-about&quot;&gt;What’s this about?&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;Oftentimes I get so immersed in what I do, one thing after the other, I forget to take a step back and notice what I’ve accomplished. It’s important to do this from time to time, so when I feel down about not doing enough in moments of downtime, I have something to look at and go, “No, I am doing my best.”&lt;&#x2F;p&gt;
&lt;p&gt;This is one such list, for what I’ve been up to this year till now. Here’s a glimpse into the life of Sheikh, halfway through 2025.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;the-list&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#the-list&quot; aria-label=&quot;Anchor link for: the-list&quot;&gt;The List&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;&lt;em&gt;[Part 1 of 3]&lt;&#x2F;em&gt;&lt;&#x2F;p&gt;
&lt;h3 id=&quot;celpip-exam&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#celpip-exam&quot; aria-label=&quot;Anchor link for: celpip-exam&quot;&gt;CELPIP Exam&lt;&#x2F;a&gt;&lt;&#x2F;h3&gt;
&lt;p&gt;Mid-January I took the CELPIP Exam in preparation for applying for my Post-Graduation Work Permit. It’s an English proficiency test comparable to IELTS, but the score band is up to 12 points, with 1:1 equivalence with the Canadian Language Benchmark (CLB) scoring system. I passed with 12 points in Listening and Writing, and 11 points in Reading and Speaking. With these results, I applied for my PGWP soon after.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;global-game-jam&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#global-game-jam&quot; aria-label=&quot;Anchor link for: global-game-jam&quot;&gt;Global Game Jam&lt;&#x2F;a&gt;&lt;&#x2F;h3&gt;
&lt;p&gt;Last week of January I participated in the Global Game Jam for the 3rd time, but it was my first time doing it solo. Previously I had participated with friends, so it was quite a different experience. I had a lot of fun making a whole game from scratch in ~2.5 days, including the graphics.&lt;&#x2F;p&gt;
&lt;p&gt;I always wanted to make a game for some old retro console, and seeing this as my chance I did just that. I chose Gameboy as my target platform and GB Studio as my engine of choice. It’s a great engine that’s easy to get started with, and one of the best way to make games for the original Gameboy and Gameboy Color. Even considering that I made the graphics from scratch while working solo, the whole game was done way ahead of time, and I had plenty of room for going around and seeing what wonderful games everyone else was making. Also met some great people from Ubisoft Halifax who gave me valuable feedback on how I can make my game even better. That’s what I’m looking to work on, now that the pressure is off.&lt;&#x2F;p&gt;
&lt;p&gt;Try Bubble Blaster here: &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;cybardev.itch.io&#x2F;bubble-blaster&quot;&gt;cybardev.itch.io&#x2F;bubble-blaster&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3 id=&quot;shiftkey-cloud-foundations&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#shiftkey-cloud-foundations&quot; aria-label=&quot;Anchor link for: shiftkey-cloud-foundations&quot;&gt;ShiftKey Cloud Foundations&lt;&#x2F;a&gt;&lt;&#x2F;h3&gt;
&lt;p&gt;Once a week through February, I attended the Cloud Foundations course by ShiftKey at Dalhousie. It was taught by Vansh Sood, who previously taught a course on GenAI, that I enjoyed. This course was a nice overview of how cloud fits into the software ecosystem, and the various providers and services available. It was also meant to help prepare for the AWS Cloud Practitioner foundational certification exam. As such, the course was mainly focused on AWS, but counterparts in Azure and GCP were discussed briefly as well.&lt;&#x2F;p&gt;
&lt;p&gt;I haven&#x27;t taken the AWS exam yet. That&#x27;s because I&#x27;m thinking of going straight to a more advanced certificate like Solutions Architect. Regardless, I&#x27;m sure the knowledge I&#x27;ve gained from this course will be helpful in my projects and beyond.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;shiftkey-practical-cybersecurity&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#shiftkey-practical-cybersecurity&quot; aria-label=&quot;Anchor link for: shiftkey-practical-cybersecurity&quot;&gt;ShiftKey Practical Cybersecurity&lt;&#x2F;a&gt;&lt;&#x2F;h3&gt;
&lt;p&gt;Once a week through March, I attended the Practical Cybersecurity course by ShiftKey at Dalhousie. It was taught by Aman Bhalla, a fellow student, but one with quite a bit of industry experience through co-ops and internships. I like that they have students teach these courses. Makes them approachable and they also know what we need because they&#x27;re currently going through the same things but are a few steps ahead. We went through topics like Information Security, Threat Analysis, Encryption, Data Protection principles, Cybersecurity Frameworks, Applications Security, Ethical Hacking, and Legal Frameworks for Cybersecurity.&lt;&#x2F;p&gt;
&lt;p&gt;I expected this course to be redundant due to another course I was doing at the time (started that one earlier), but this ended up accelerating my learning in that course.&lt;&#x2F;p&gt;
&lt;p&gt;More on the other course in the next part of this series…&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>Half-Life</title>
          <pubDate>Tue, 23 May 2023 00:00:00 -0300</pubDate>
          <author>cybardev</author>
          <link>https://cybar.dev/blog/half-life/</link>
          <guid>https://cybar.dev/blog/half-life/</guid>
          <description xml:base="https://cybar.dev/blog/half-life/">&lt;p&gt;Schrödinger&#x27;s Cat&lt;br &#x2F;&gt;
Looks around curiously.&lt;br &#x2F;&gt;
Its fate uncertain but it cares not&lt;br &#x2F;&gt;
For it&#x27;s unaware of its gravity.&lt;&#x2F;p&gt;
&lt;p&gt;Schrödinger&#x27;s Cat&lt;br &#x2F;&gt;
It meows and yawns&lt;br &#x2F;&gt;
And lays its head down.&lt;br &#x2F;&gt;
Lush black fur, trimmed with care.&lt;br &#x2F;&gt;
He slips into a slumber.&lt;&#x2F;p&gt;
&lt;p&gt;Schrödinger&#x27;s Cat&lt;br &#x2F;&gt;
Will he die?&lt;br &#x2F;&gt;
Or will he hold onto his nine lives?&lt;br &#x2F;&gt;
Nobody knows, until&lt;br &#x2F;&gt;
The observer takes a peek.&lt;&#x2F;p&gt;
&lt;p&gt;Curiosity killed the cat, they say.&lt;br &#x2F;&gt;
Was he ever even that curious?&lt;br &#x2F;&gt;
He was trapped in a box,&lt;br &#x2F;&gt;
With not much else&lt;br &#x2F;&gt;
And nowhere to wander away.&lt;&#x2F;p&gt;
&lt;p&gt;Schrödinger&#x27;s Cat&lt;br &#x2F;&gt;
The observer saw&lt;br &#x2F;&gt;
Sleeping soundly.&lt;br &#x2F;&gt;
His spirit in peace&lt;br &#x2F;&gt;
Free from the bounds&lt;br &#x2F;&gt;
Of the cold hard earth&lt;br &#x2F;&gt;
That gifted him cruelty.&lt;&#x2F;p&gt;
&lt;p&gt;He had a chance, they say,&lt;br &#x2F;&gt;
Fifty-fifty - to pass on or to survive.&lt;br &#x2F;&gt;
Till the lid was popped&lt;br &#x2F;&gt;
He was half alive.&lt;br &#x2F;&gt;
Or so the science said.&lt;br &#x2F;&gt;
It wasn&#x27;t his fault, definitely not.&lt;br &#x2F;&gt;
Nor of the observer&#x27;s eye.&lt;&#x2F;p&gt;
&lt;p&gt;Tis but a twist of fate, just that&lt;br &#x2F;&gt;
Nothing to do about it.&lt;br &#x2F;&gt;
His spirit passed on,&lt;br &#x2F;&gt;
Peacefully I hope.&lt;br &#x2F;&gt;
All we can do is pray.&lt;&#x2F;p&gt;
&lt;p&gt;Schrödinger&#x27;s Cat&lt;br &#x2F;&gt;
We say goodbye.&lt;br &#x2F;&gt;
We bid farewell&lt;br &#x2F;&gt;
With tears in our eyes.&lt;br &#x2F;&gt;
But we forget him next day&lt;br &#x2F;&gt;
And go on with our lives.&lt;br &#x2F;&gt;
Like nothing ever happened.&lt;br &#x2F;&gt;
It&#x27;s as if he never existed.&lt;&#x2F;p&gt;
&lt;p&gt;It&#x27;s okay. Life goes on.&lt;br &#x2F;&gt;
The tides of time&lt;br &#x2F;&gt;
Wait for none.&lt;br &#x2F;&gt;
I just hope that&lt;br &#x2F;&gt;
Schrödinger&#x27;s Cat&lt;br &#x2F;&gt;
Is remembered sometimes&lt;br &#x2F;&gt;
By someone.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>Java Lists</title>
          <pubDate>Mon, 22 Mar 2021 22:36:56 +0600</pubDate>
          <author>cybardev</author>
          <link>https://cybar.dev/blog/java-lists/</link>
          <guid>https://cybar.dev/blog/java-lists/</guid>
          <description xml:base="https://cybar.dev/blog/java-lists/">&lt;p&gt;&lt;em&gt;PS: This post is structured similarly to my &lt;a href=&quot;..&#x2F;java-arrays&#x2F;index.html&quot;&gt;post about arrays&lt;&#x2F;a&gt;. I will also refer to array concepts, so you may want to read that first if you&#x27;re new to Java collections.&lt;&#x2F;em&gt;&lt;&#x2F;p&gt;
&lt;h2 id=&quot;what-are-lists&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#what-are-lists&quot; aria-label=&quot;Anchor link for: what-are-lists&quot;&gt;What are lists?&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;Think of lists like a row of cardboard boxes. These boxes can be used to store different types of data - &lt;code&gt;ints&lt;&#x2F;code&gt;, &lt;code&gt;Strings&lt;&#x2F;code&gt;, even custom data types like &lt;code&gt;Person&lt;&#x2F;code&gt;. You can add more boxes to the row, remove boxes from the row, or even have no boxes at all!&lt;&#x2F;p&gt;
&lt;p&gt;One important thing to note is that you can have a variable number of these boxes for each list you make. This is different from arrays, as arrays can only have a constant number of boxes. There are two main types of lists in Java - ArrayList and LinkedList. They can be used identically, but are very different in how they store data. While making the list, you&#x27;ll need to tell Java which kind of list you&#x27;d like to have. If you tell Java that this list will have 10 items, then you will always be able to change its size later to accommodate more or less items.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;making-new-lists&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#making-new-lists&quot; aria-label=&quot;Anchor link for: making-new-lists&quot;&gt;Making new lists&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;There are two ways of creating lists in Java as described below. Make sure you set the type of the variable as List and not ArrayList or LinkedList. This makes your code more modular and portable so that if you ever want to convert between ArrayList and LinkedList, you only need to change it in one place instead of having to re-factor the whole code.&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;The first way&lt;&#x2F;strong&gt; creates a list of Strings without specifying initial items. The type of list must be specified between angle brackets (&lt;code&gt;&amp;lt;&lt;&#x2F;code&gt;, &lt;code&gt;&amp;gt;&lt;&#x2F;code&gt;).&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;java&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-storage z-type&quot;&gt;List&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-type&quot;&gt;String&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt; fruits&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt; =&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-control&quot;&gt; new&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-type&quot;&gt; ArrayList&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment&quot;&gt;&#x2F;&#x2F;&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment&quot;&gt; or&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-storage z-type&quot;&gt;List&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-type&quot;&gt;String&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt; fruits&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt; =&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-control&quot;&gt; new&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-type&quot;&gt; LinkedList&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This way of making lists is best used when you don’t know what items the list should initially have, but you know the number of values may vary. An example of this may be in a program that asks the users for their grades throughout a course, and you don’t know the maximum number of tests there are in that course.&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;The second way&lt;&#x2F;strong&gt; creates a list of 3 Strings, and here we&#x27;re providing each box with an initial value (which can be changed later as needed).&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;java&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-storage z-type&quot;&gt;List&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-type&quot;&gt;String&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt; fruits&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt; =&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-control&quot;&gt; new&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-type&quot;&gt; ArrayList&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt;Arrays&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;asList&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt;Apple&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;,&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt;Banana&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;,&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt;Orange&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment&quot;&gt;&#x2F;&#x2F;&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment&quot;&gt; or&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-storage z-type&quot;&gt;List&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-type&quot;&gt;String&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt; fruits&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt; =&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-control&quot;&gt; new&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-type&quot;&gt; LinkedList&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt;Arrays&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;asList&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt;Apple&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;,&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt;Banana&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;,&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt;Orange&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Here&#x27;s a visual representation of the second list:&lt;&#x2F;p&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Box&lt;&#x2F;th&gt;&lt;th&gt;Index&lt;&#x2F;th&gt;&lt;th&gt;Item&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;1&lt;&#x2F;td&gt;&lt;td&gt;0&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;Apple&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;2&lt;&#x2F;td&gt;&lt;td&gt;1&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;Banana&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;3&lt;&#x2F;td&gt;&lt;td&gt;2&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;Orange&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;p&gt;This way is best used when you know what values you want to start with. An example of this may be when you want a list with the names of all the countries in the world. You could also make a list the first way and add values later, as I’ll show below.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;manipulating-list-values&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#manipulating-list-values&quot; aria-label=&quot;Anchor link for: manipulating-list-values&quot;&gt;Manipulating list values&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;u&gt;Adding values&lt;&#x2F;u&gt;:&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;Let&#x27;s say you like to keep things clean and simple, and want to use the first way to make an list of countries.&lt;br &#x2F;&gt;How would you add the country names to the list?&lt;&#x2F;p&gt;
&lt;p&gt;Here&#x27;s how: &lt;code&gt;listName.add(newValue);&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;p&gt;For example:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;java&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-storage z-type&quot;&gt;List&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-type&quot;&gt;String&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt; countries&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt; =&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-control&quot;&gt; new&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-type&quot;&gt; ArrayList&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-variable&quot;&gt;countries&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;add&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt;Atlantis&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-variable&quot;&gt;countries&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;add&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt;Bangladesh&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment&quot;&gt;&#x2F;&#x2F;&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment&quot;&gt; and so on...&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-variable&quot;&gt;countries&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;add&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt;Wonderland&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;ul&gt;
&lt;li&gt;&lt;u&gt;Modifying values&lt;&#x2F;u&gt;:&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;To &lt;em&gt;re-assign&lt;&#x2F;em&gt; values, you’ll need to use the &lt;code&gt;set&lt;&#x2F;code&gt; method:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;java&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-variable&quot;&gt;countries&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;set&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric&quot;&gt;1&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;,&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt;Neverland&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This will change the value of the 2nd box (at index 1) from &lt;code&gt;Bangladesh&lt;&#x2F;code&gt; to &lt;code&gt;Neverland&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;u&gt;Removing values&lt;&#x2F;u&gt;:&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;To remove the value at a specific index:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;java&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-variable&quot;&gt;countries&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;remove&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric&quot;&gt;1&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;To remove the first occurrence of the specified value:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;java&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-variable&quot;&gt;countries&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;remove&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt;Neverland&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;To remove all occurrences of the specified value:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;java&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-variable&quot;&gt;countries&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;removeAll&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt;Neverland&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;calling-list-elements&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#calling-list-elements&quot; aria-label=&quot;Anchor link for: calling-list-elements&quot;&gt;Calling list elements&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;Just like how people can be called by their names, these &lt;em&gt;elements&lt;&#x2F;em&gt; can be called by their &lt;em&gt;indices&lt;&#x2F;em&gt;. Elements is a technical term for the values in the &quot;boxes&quot; and Index is a technical term for the &quot;position&quot; of the boxes, and the first box is at index 0. So, the n^th^ box will always be at index &lt;code&gt;(n-1)&lt;&#x2F;code&gt;, as long as n is at least 1.&lt;&#x2F;p&gt;
&lt;p&gt;To access the nth list element in Java, simply call it by its index using the &lt;code&gt;get&lt;&#x2F;code&gt; method, like &lt;code&gt;fruits.get(1)&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;An example of it in action:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;java&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-variable&quot;&gt;System&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt;out&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;println&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt;fruits&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;get&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric&quot;&gt;1&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This would print &lt;code&gt;Banana&lt;&#x2F;code&gt; to the console. Banana is the &lt;code&gt;2nd&lt;&#x2F;code&gt; element, so its index is &lt;code&gt;2 - 1 = 1&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;length-of-a-list&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#length-of-a-list&quot; aria-label=&quot;Anchor link for: length-of-a-list&quot;&gt;Length of a list&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;After all that creating, assigning and calling lists and their elements, you might not remember what the length of each one is. Well, fear not, because Java has you covered. Lists have a handy little getter method that you can use to know the length of a list. To access it, simply use &lt;code&gt;listName.size()&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;For example:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;java&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-variable&quot;&gt;System&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt;out&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;println&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt;countries&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;size&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment&quot;&gt;&#x2F;&#x2F;&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment&quot;&gt; output: 195&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-variable&quot;&gt;System&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt;out&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;println&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt;fruits&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;size&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment&quot;&gt;&#x2F;&#x2F;&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment&quot;&gt; output: 3&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;sorting-lists&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#sorting-lists&quot; aria-label=&quot;Anchor link for: sorting-lists&quot;&gt;Sorting lists&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;In case you assigned the names of the countries randomly and now want them sorted in alphabetical order, you can use the &lt;code&gt;Collections.sort()&lt;&#x2F;code&gt; method from the &lt;code&gt;java.util.Collections&lt;&#x2F;code&gt; class.&lt;&#x2F;p&gt;
&lt;p&gt;Here&#x27;s how to use it:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;java&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-keyword z-other&quot;&gt;import&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-modifier&quot;&gt; java&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-modifier&quot;&gt;util&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-modifier&quot;&gt;Collections&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment&quot;&gt;&#x2F;&#x2F;&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment&quot;&gt; create the unsorted list of countries here&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-variable&quot;&gt;Collections&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;sort&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;countries&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment&quot;&gt;&#x2F;&#x2F;&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment&quot;&gt; the list &amp;quot;countries&amp;quot; is now sorted&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This will also sort numbers in numerical order, and other types in their natural order. It will also sort custom data types implementing the &lt;code&gt;Comparable&lt;&#x2F;code&gt; interface as defined in their &lt;code&gt;compareTo&lt;&#x2F;code&gt; method.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;looping-over-lists&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#looping-over-lists&quot; aria-label=&quot;Anchor link for: looping-over-lists&quot;&gt;Looping over lists&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;The process of looping through collections like lists, lists, sets, etc. is also known as &lt;em&gt;iterating&lt;&#x2F;em&gt;. When we &lt;em&gt;iterate&lt;&#x2F;em&gt; over an list, we&#x27;re simply checking the value in each box of the list one by one and usually performing the same actions with each value, unless specified otherwise by some logic control (&lt;code&gt;if-else&lt;&#x2F;code&gt; and such).&lt;&#x2F;p&gt;
&lt;p&gt;There are a few ways to iterate over lists:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Traditional &lt;code&gt;for&lt;&#x2F;code&gt; loop:&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;java&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-storage z-type&quot;&gt;String&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt; country&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-keyword z-control&quot;&gt;for&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; (&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-type&quot;&gt;int&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt; i&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt; =&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric&quot;&gt; 0&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;span&gt; i &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt; countries&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt;length&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;span&gt; i&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;++&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-keyword z-control&quot;&gt;    if&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; (&lt;&#x2F;span&gt;&lt;span&gt;i &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;!=&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric&quot;&gt; 42&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        country &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;=&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt; countries&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;get&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;i&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-variable&quot;&gt;        System&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt;out&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;println&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;country&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation&quot;&gt;    }&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-control&quot;&gt; else&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-variable&quot;&gt;        System&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt;out&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;println&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;            &amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt;The answer to life, the universe &lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;            +&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt;and everything...&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation&quot;&gt;        )&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation&quot;&gt;    }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;for-each&lt;&#x2F;code&gt; loop:&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;java&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-keyword z-control&quot;&gt;for&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; (&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-type&quot;&gt;String&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt; country&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-control&quot;&gt; :&lt;&#x2F;span&gt;&lt;span&gt; countries&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-variable&quot;&gt;    System&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt;out&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;println&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;country&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;while&lt;&#x2F;code&gt; loop:&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;java&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-storage z-type&quot;&gt;int&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt; i&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt; =&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric&quot;&gt; 0&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-storage z-type&quot;&gt;String&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt; country&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-keyword z-control&quot;&gt;while&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; (&lt;&#x2F;span&gt;&lt;span&gt;i &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt; countries&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt;length&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-keyword z-control&quot;&gt;    if&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; (&lt;&#x2F;span&gt;&lt;span&gt;i &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;!=&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric&quot;&gt; 42&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        country &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;=&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt; countries&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;get&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;i&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-variable&quot;&gt;        System&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt;out&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;println&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;country&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation&quot;&gt;    }&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-control&quot;&gt; else&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-variable&quot;&gt;        System&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt;out&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;println&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;            &amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt;The answer to life, the universe &lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;            +&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt;and everything...&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation&quot;&gt;        )&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation&quot;&gt;    }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    i&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;++&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;As you can see, while the &lt;code&gt;for-each&lt;&#x2F;code&gt; loop makes life easier for simple iterations, you have slightly less control over things as it doesn&#x27;t give you the index easily. We can, however, mitigate that problem by using a variable to track the index, like in the &lt;code&gt;while&lt;&#x2F;code&gt; loop:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;java&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-storage z-type&quot;&gt;int&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt; i&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt; =&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric&quot;&gt; 0&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-keyword z-control&quot;&gt;for&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; (&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-type&quot;&gt;String&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt; country&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-control&quot;&gt; :&lt;&#x2F;span&gt;&lt;span&gt; countries&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-keyword z-control&quot;&gt;    if&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; (&lt;&#x2F;span&gt;&lt;span&gt;i &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;!=&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric&quot;&gt; 42&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-variable&quot;&gt;        System&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt;out&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;println&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;country&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation&quot;&gt;    }&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-control&quot;&gt; else&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-variable&quot;&gt;        System&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt;out&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;println&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;            &amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt;The answer to life, the universe &lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;            +&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt;and everything...&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation&quot;&gt;        )&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation&quot;&gt;    }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    i&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;++&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Or you could just use the while loop.&lt;&#x2F;p&gt;
&lt;p&gt;However, this kind of &lt;code&gt;for-each&lt;&#x2F;code&gt; loop does have an advantage. The variable &lt;code&gt;country&lt;&#x2F;code&gt; is created and used within the scope of this loop alone, so you can create a variable with the same name outside the scope and use it without conflicts. It can be done in the other loops too, but is much cleaner, easily readable and more efficient this way. Do note that the variable to track index, &lt;code&gt;i&lt;&#x2F;code&gt;, is declared outside the scope of the &lt;code&gt;for-each&lt;&#x2F;code&gt; loop, so make sure to be careful about that later. Next time you want to use it in that scope, you should reset it to &lt;code&gt;0&lt;&#x2F;code&gt; before you perform any operations with it, unless you actually want to retain the value it has after going through the loop.&lt;&#x2F;p&gt;
&lt;p&gt;It&#x27;s often important to choose the correct loop for the task at hand. Take a deep breath, relax and think about which loop might put you at an advantage.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;a-better-way-to-iterate&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#a-better-way-to-iterate&quot; aria-label=&quot;Anchor link for: a-better-way-to-iterate&quot;&gt;A better way to iterate&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;If you tried to modify list elements inside loops and had your program crash with a &lt;code&gt;ConcurrentModificationException&lt;&#x2F;code&gt;, no need to panic. It’s just Java being cautious so that nothing weird happens in the program. To get around this, we need to use list iterators and the methods that come with them which we can use to manipulate the list safely.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;em&gt;“With great power comes great responsibility.”&lt;br &#x2F;&gt;- Uncle Ben&lt;&#x2F;em&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Here’s a little text filtering program to demonstrate &lt;code&gt;ListIterator&lt;&#x2F;code&gt;s in action:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;java&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-keyword z-other&quot;&gt;import&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-modifier&quot;&gt; java&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-modifier&quot;&gt;util&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-modifier&quot;&gt;ArrayList&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-keyword z-other&quot;&gt;import&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-modifier&quot;&gt; java&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-modifier&quot;&gt;util&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-modifier&quot;&gt;List&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-keyword z-other&quot;&gt;import&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-modifier&quot;&gt; java&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-modifier&quot;&gt;util&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-modifier&quot;&gt;ListIterator&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-storage z-modifier&quot;&gt;public&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-modifier&quot;&gt; class&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name&quot;&gt; FilterLines&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-storage z-modifier&quot;&gt;    public&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-modifier&quot;&gt; static&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-type&quot;&gt; void&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt; main&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-type&quot;&gt;String&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;[&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;]&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt; args&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment&quot;&gt;        &#x2F;&#x2F;&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment&quot;&gt; create variables&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-storage z-type&quot;&gt;        List&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-type&quot;&gt;String&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt; lines&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt; =&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-control&quot;&gt; new&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-type&quot;&gt; ArrayList&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-storage z-type&quot;&gt;        ListIterator&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-type&quot;&gt;String&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt; linesIterator&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-comment&quot;&gt; &#x2F;&#x2F;&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment&quot;&gt; declare the iterator&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-storage z-type&quot;&gt;        String&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt; currentLine&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment&quot;&gt;        &#x2F;&#x2F;&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment&quot;&gt; add lines to the list of lines to filter&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-variable&quot;&gt;        lines&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;add&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt;There was a line with the word bad here.&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-variable&quot;&gt;        lines&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;add&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt;There was another bad line here.&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-variable&quot;&gt;        lines&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;add&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt;This line will stay as is.&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-variable&quot;&gt;        lines&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;add&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt;Here&amp;#39;s a good line.&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-variable&quot;&gt;        lines&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;add&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt;Have a good day!&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment&quot;&gt;        &#x2F;&#x2F;&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment&quot;&gt; code to filter the lines&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        linesIterator &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;=&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt; lines&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;listIterator&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-comment&quot;&gt; &#x2F;&#x2F;&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment&quot;&gt; assign the iterator&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-keyword z-control&quot;&gt;        while&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; (&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt;linesIterator&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;hasNext&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            currentLine &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;=&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt; linesIterator&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;next&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-keyword z-control&quot;&gt;            if&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; (&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt;currentLine&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;contains&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt;bad&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-variable&quot;&gt;                linesIterator&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;remove&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation&quot;&gt;            }&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-control&quot;&gt; else&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-control&quot;&gt; if&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; (&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt;currentLine&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;contains&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt;good&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-variable&quot;&gt;                linesIterator&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;set&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt;currentLine&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;toUpperCase&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation&quot;&gt;            }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation&quot;&gt;        }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment&quot;&gt;        &#x2F;&#x2F;&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment&quot;&gt; print out the lines&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-keyword z-control&quot;&gt;        for&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; (&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-type&quot;&gt;String&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt; line&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-control&quot;&gt; :&lt;&#x2F;span&gt;&lt;span&gt; lines&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-variable&quot;&gt;            System&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt;out&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;println&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;line&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation&quot;&gt;        }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation&quot;&gt;    }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-class z-end&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;strong&gt;PS&lt;&#x2F;strong&gt;: It&#x27;s important to assign the list iterator right before iteration as on &lt;code&gt;line 20&lt;&#x2F;code&gt;. It can be declared beforehand, though, as on &lt;code&gt;line 9&lt;&#x2F;code&gt;. This is because the &lt;code&gt;listName.listIterator()&lt;&#x2F;code&gt; method gets the &lt;strong&gt;current&lt;&#x2F;strong&gt; state of the list and creates a &lt;code&gt;ListIterator&lt;&#x2F;code&gt; object out of it. Changes you make directly to the list will not update the iterator and may result in unexpected behaviour.&lt;&#x2F;p&gt;
&lt;p&gt;Running the above program produces the following output:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;This line will stay as is.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;HERE&amp;#39;S A GOOD LINE.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;HAVE A GOOD DAY!&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;As you can see, the lines with “bad” were removed and the lines with “good” were converted to uppercase.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;check-for-identical-lists&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#check-for-identical-lists&quot; aria-label=&quot;Anchor link for: check-for-identical-lists&quot;&gt;Check for identical lists&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;Now that you&#x27;ve made some lists, you might want to check if two lists contain the same things. We could of course make a method to compare two given lists using loops and &lt;code&gt;if-else&lt;&#x2F;code&gt; control, but that would be too much work. Thus, the &lt;code&gt;equals&lt;&#x2F;code&gt; method will certainly come in handy and take some load off our shoulders.&lt;&#x2F;p&gt;
&lt;p&gt;Here&#x27;s how it works:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;java&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment&quot;&gt;&#x2F;&#x2F;&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment&quot;&gt; make a list, countries&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment&quot;&gt;&#x2F;&#x2F;&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment&quot;&gt; make a list, fruits&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-storage z-type&quot;&gt;boolean&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt; isEqual&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt; =&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt; countries&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;equals&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;fruits&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-variable&quot;&gt;System&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt;out&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;println&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;isEqual&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment&quot;&gt;&#x2F;&#x2F;&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment&quot;&gt; output: false&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment&quot;&gt;&#x2F;&#x2F;&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment&quot;&gt; output will be &amp;quot;true&amp;quot; if the given lists are equal&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;helpful-resources&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#helpful-resources&quot; aria-label=&quot;Anchor link for: helpful-resources&quot;&gt;Helpful resources&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;Here are some resources I use to learn Java. I don&#x27;t memorise anything, but rather just look them up when I need to. They&#x27;re all great sites to learn Java (some have other languages too) and I hope you find them helpful.&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;docs.oracle.com&#x2F;javase&#x2F;8&#x2F;docs&#x2F;api&#x2F;java&#x2F;util&#x2F;List.html&quot;&gt;Java 8 docs of the List interface&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;docs.oracle.com&#x2F;javase&#x2F;8&#x2F;docs&#x2F;api&#x2F;java&#x2F;util&#x2F;ArrayList.html&quot;&gt;Java 8 docs of the ArrayList class&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;docs.oracle.com&#x2F;javase&#x2F;8&#x2F;docs&#x2F;api&#x2F;java&#x2F;util&#x2F;LinkedList.html&quot;&gt;Java 8 docs of the LinkedList class&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;docs.oracle.com&#x2F;javase&#x2F;8&#x2F;docs&#x2F;api&#x2F;java&#x2F;util&#x2F;ListIterator.html&quot;&gt;Java 8 docs of the ListIterator interface&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;www.sololearn.com&#x2F;learning&#x2F;1068&quot;&gt;SoloLearn&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;www.geeksforgeeks.org&#x2F;java&#x2F;&quot;&gt;GeeksforGeeks&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;www.w3schools.com&#x2F;java&#x2F;&quot;&gt;W3schools&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;www.tutorialspoint.com&#x2F;java&#x2F;&quot;&gt;tutorialspoint&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;www.javatpoint.com&#x2F;java-tutorial&quot;&gt;Javatpoint&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h2 id=&quot;conclusion&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#conclusion&quot; aria-label=&quot;Anchor link for: conclusion&quot;&gt;Conclusion&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;That&#x27;s all about lists for now. That should cover the basics of lists, but do let me know in the comments if I&#x27;ve missed something or made a mistake somewhere.&lt;&#x2F;p&gt;
&lt;p&gt;I hope it was helpful for you. Thanks for reading through. See you later.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>My Experience with Online Learning</title>
          <pubDate>Mon, 22 Mar 2021 13:29:40 +0600</pubDate>
          <author>cybardev</author>
          <link>https://cybar.dev/blog/online-learning/</link>
          <guid>https://cybar.dev/blog/online-learning/</guid>
          <description xml:base="https://cybar.dev/blog/online-learning/">&lt;h2 id=&quot;my-story&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#my-story&quot; aria-label=&quot;Anchor link for: my-story&quot;&gt;My Story&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;I&#x27;m currently an undergraduate student studying at Saint Mary&#x27;s University, Nova Scotia, Canada. As my major, I&#x27;ve chosen Computer Science (they call it computing science, but it&#x27;s practically the same thing), as I had a keen interest in computers, science and technology from a very young age. Because of the ongoing pandemic, our school has decided to provide online classes with some optional in-person experiences. To save money on residence, food and other costs, I&#x27;ve decided to do online classes from Bangladesh until in-person classes fully begin. Here&#x27;s my experience with online learning thus far.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;the-woes&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#the-woes&quot; aria-label=&quot;Anchor link for: the-woes&quot;&gt;The Woes&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;Online classes can be hectic, especially if your school is on the other side of the globe. Ideally, you&#x27;d want to start your morning with classes, take some rest and start working on your assignments in the afternoon or evening. With online classes, I&#x27;m having to do the opposite - assignments in the morning, get exhausted from all the work, barely have any energy for classes in the evening&#x2F;night. On Wednesday nights (or Thursday morning) at 3 AM, I have a 2 hr recitation class too, so that&#x27;s not helping my health either.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;the-joys&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#the-joys&quot; aria-label=&quot;Anchor link for: the-joys&quot;&gt;The Joys&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;That being said, I&#x27;m loving the different atmosphere of foreign universities. The teachers are mostly extremely helpful (not all though) and I&#x27;m glad to say my CS professor is the most joyful and inspiring character I&#x27;ve met out of all the professors there (Maths professor is the least, sadly). That teacher has humour, intellect, experience, a Ph.D. (of course he does) and is a complete joy to learn from. I&#x27;m glad I got him from the first year in my major course.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;make-friends&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#make-friends&quot; aria-label=&quot;Anchor link for: make-friends&quot;&gt;Make Friends&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;I&#x27;m also enjoying the virtual company of my peers, although I&#x27;d love to meet them in person. As that&#x27;s currently impossible, this is the best we can get. I&#x27;m thrilled to be able to share ideas and converse with so many people with similar interests and passions. I&#x27;ve also been able to build up a Discord server of 230+ students (many inactive accounts, but whatever. I tried). The owner of the server was kind enough to let me handle it when it was only about 20 people, and together, myself, the owner, and a senior at SMU were able to build it up to what it is today, with a little help from some of the members. Now we have different channels for different courses, reaction roles so that we can choose what course channels we can see and of course, many enthusiastic and active members.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;explore-opportunities&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#explore-opportunities&quot; aria-label=&quot;Anchor link for: explore-opportunities&quot;&gt;Explore Opportunities&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;I&#x27;ve even become part of a team of enthusiastic CS undergrads and we&#x27;re hopefully set to make a little project of ours - a visual novel game - to practice our skills, learn new ones and get some hands-on experience in working with a team on a real project. A good idea if you&#x27;re looking to build up your portfolio and have a good first impression on potential employers.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;time-management&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#time-management&quot; aria-label=&quot;Anchor link for: time-management&quot;&gt;Time Management&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;Make sure you use your time wisely though, as scheduling is very important. If you procrastinate, it becomes very difficult to cope up with the horde of assignments, quizzes, tests, recitations and everything else the University throws at you. Even though I managed to do a 2-month assignment in 2 days and still scored 28 out of 30 (don&#x27;t be me. it was insanely exhausting). Be on top of your schedule and you&#x27;ll be fine.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;mental-health&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#mental-health&quot; aria-label=&quot;Anchor link for: mental-health&quot;&gt;Mental Health&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;Many universities, including mine, offer many free workshops and counselling sessions throughout the course of the degree. Make sure you take full advantage of these and always mail the advisors, counsellors and professors whenever you&#x27;re in a pinch. They&#x27;re really helpful and understanding and will patiently guide you through whatever you&#x27;re having trouble with. Also, please do keep a check on your mental health. Many students face issues for a variety of reasons and there are often free counselling sessions available. Make your money worth it, and don&#x27;t neglect yourself.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;your-story&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#your-story&quot; aria-label=&quot;Anchor link for: your-story&quot;&gt;Your Story&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;Something important some of us forget to do in school is building up a network of peers, seniors and professors, and make memories that enrich your life. While grades are pretty important still (because we study in an education system for the 1800s), these human resources are such that they can bring a lot more value to your life. University is the time to explore your interests, so make some friends, do personal projects, join or form clubs and enjoy your time.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;strong&gt;THIS IS YOUR TIME TO SHINE. DO YOUR BEST. (^_^)&lt;&#x2F;strong&gt;&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>Java Arrays</title>
          <pubDate>Mon, 08 Mar 2021 16:03:05 +0600</pubDate>
          <author>cybardev</author>
          <link>https://cybar.dev/blog/java-arrays/</link>
          <guid>https://cybar.dev/blog/java-arrays/</guid>
          <description xml:base="https://cybar.dev/blog/java-arrays/">&lt;h2 id=&quot;what-are-arrays&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#what-are-arrays&quot; aria-label=&quot;Anchor link for: what-are-arrays&quot;&gt;What are arrays?&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;Think of arrays like a row of cardboard boxes. These boxes can be used to store different types of data - &lt;code&gt;ints&lt;&#x2F;code&gt;, &lt;code&gt;Strings&lt;&#x2F;code&gt;, even custom data types like &lt;code&gt;Person&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;One important thing to note is that you can only have a constant number of these boxes for each array you make. While making the array, if you tell Java that this array will have 10 items, then that array will always be able to contain up to 10 items - no more, no less, no changes to this size. You can store less than 10 items in that array and leave the others at default value (to change them later), but this might have weird effects on your program and is better avoided.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;making-new-arrays&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#making-new-arrays&quot; aria-label=&quot;Anchor link for: making-new-arrays&quot;&gt;Making new arrays&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;There are two ways of creating arrays in Java:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;The first way&lt;&#x2F;strong&gt; creates an array of Strings with a fixed number of the &quot;boxes&quot; (3 in the example below), and each box contains a default value given to it by Java. For String arrays like this one, that value is &lt;code&gt;null&lt;&#x2F;code&gt;, which isn&#x27;t actually a String, but you can read more on that &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;www.geeksforgeeks.org&#x2F;interesting-facts-about-null-in-java&#x2F;&quot;&gt;here&lt;&#x2F;a&gt;.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;java&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-storage z-type&quot;&gt;String&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;[&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;]&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt; fruits&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt; =&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-control&quot;&gt; new&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-type&quot;&gt; String&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;[&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric&quot;&gt;3&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;]&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Here&#x27;s a visual representation of the first array:&lt;&#x2F;p&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Box&lt;&#x2F;th&gt;&lt;th&gt;Index&lt;&#x2F;th&gt;&lt;th&gt;Item&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;1&lt;&#x2F;td&gt;&lt;td&gt;0&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;null&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;2&lt;&#x2F;td&gt;&lt;td&gt;1&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;null&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;3&lt;&#x2F;td&gt;&lt;td&gt;2&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;null&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;p&gt;This way of making arrays is best used when you know how many items the array should have, but you don&#x27;t know what the values will be. An example of this may be in a program that asks the users for their grades throughout a course, and you know the maximum number of tests there are in that course.&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;The second way&lt;&#x2F;strong&gt; creates an array of 3 Strings too, but here, we&#x27;re providing each box with an initial value, instead of keeping the default value.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;java&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-storage z-type&quot;&gt;String&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;[&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;]&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt; fruits&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt; =&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; {&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt;Apple&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;,&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt;Banana&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;,&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt;Orange&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;}&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Here&#x27;s a visual representation of the second array:&lt;&#x2F;p&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Box&lt;&#x2F;th&gt;&lt;th&gt;Index&lt;&#x2F;th&gt;&lt;th&gt;Item&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;1&lt;&#x2F;td&gt;&lt;td&gt;0&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;Apple&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;2&lt;&#x2F;td&gt;&lt;td&gt;1&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;Banana&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;3&lt;&#x2F;td&gt;&lt;td&gt;2&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;Orange&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;p&gt;This way is best used when you know what values you want to start with. An example of this may be when you want an array with the names of all the countries in the world. It would be rather painful if you first made an array of nearly 200 Strings with default value and then added each country name individually.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;assigning-values-to-arrays&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#assigning-values-to-arrays&quot; aria-label=&quot;Anchor link for: assigning-values-to-arrays&quot;&gt;Assigning values to arrays&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;Let&#x27;s say you&#x27;re very hard working and like to take challenges, and want to use the first way to make an array of countries. How would you set the values to be country names instead of &lt;code&gt;null&lt;&#x2F;code&gt;?&lt;&#x2F;p&gt;
&lt;p&gt;Here&#x27;s how: &lt;code&gt;arrayName[index] = newValue;&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;p&gt;For example:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;java&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-storage z-type&quot;&gt;String&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;[&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;]&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt; countries&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt; =&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-control&quot;&gt; new&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-type&quot;&gt; String&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;[&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric&quot;&gt;195&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;]&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;countries&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;[&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric&quot;&gt;0&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;]&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt; =&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt;Atlantis&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;countries&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;[&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric&quot;&gt;1&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;]&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt; =&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt;Bangladesh&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment&quot;&gt;&#x2F;&#x2F;&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment&quot;&gt; and so on...&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;countries&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;[&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric&quot;&gt;194&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;]&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt; =&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt;Wonderland&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;You can also use this to &lt;em&gt;re-assign&lt;&#x2F;em&gt; values:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;java&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;countries&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;[&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric&quot;&gt;1&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;]&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt; =&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt;Neverland&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This will change the value of the 2nd box (at index 1) from &lt;code&gt;Bangladesh&lt;&#x2F;code&gt; to &lt;code&gt;Neverland&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;calling-array-elements&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#calling-array-elements&quot; aria-label=&quot;Anchor link for: calling-array-elements&quot;&gt;Calling array elements&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;Just like how people can be called by their names, these &lt;em&gt;elements&lt;&#x2F;em&gt; can be called by their &lt;em&gt;indices&lt;&#x2F;em&gt;. Elements is a technical term for the values in the &quot;boxes&quot; and Index is a technical term for the &quot;position&quot; of the boxes, and the first box is at index 0. So, the (n)th box will always be at index (n-1), as long as n is at least 1.&lt;&#x2F;p&gt;
&lt;p&gt;To access the nth array element in Java, simply call it by its index, like &lt;code&gt;fruits[1]&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;An example of it in action:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;java&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-variable&quot;&gt;System&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt;out&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;println&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;fruits&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;[&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric&quot;&gt;1&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;]&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This would print &lt;code&gt;Banana&lt;&#x2F;code&gt; to the console. Banana is the &lt;code&gt;2nd&lt;&#x2F;code&gt; element, so its index is &lt;code&gt;2-1 = 1&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;length-of-an-array&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#length-of-an-array&quot; aria-label=&quot;Anchor link for: length-of-an-array&quot;&gt;Length of an Array&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;After all that creating, assigning and calling arrays and their elements, you might not remember what the length of each one is. Well, fear not, because Java has you covered. Arrays have a really nice property that you can use to know the length of an array. When each array is created, it&#x27;s assigned an instance variable with the name &lt;code&gt;length&lt;&#x2F;code&gt; that stores how many items there can be in the array. To access it, simply use &lt;code&gt;arrayName.length&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;For example:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;java&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-variable&quot;&gt;System&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt;out&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;println&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt;countries&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt;length&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment&quot;&gt;&#x2F;&#x2F;&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment&quot;&gt; output: 195&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-variable&quot;&gt;System&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt;out&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;println&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt;fruits&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt;length&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment&quot;&gt;&#x2F;&#x2F;&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment&quot;&gt; output: 3&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;sorting-arrays&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#sorting-arrays&quot; aria-label=&quot;Anchor link for: sorting-arrays&quot;&gt;Sorting Arrays&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;In case you assigned the names of the countries randomly and now want them sorted in alphabetical order, you can use the &lt;code&gt;Arrays.sort()&lt;&#x2F;code&gt; method from the &lt;code&gt;java.util.Arrays&lt;&#x2F;code&gt; class.&lt;&#x2F;p&gt;
&lt;p&gt;Here&#x27;s how to use it:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;java&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-keyword z-other&quot;&gt;import&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-modifier&quot;&gt; java&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-modifier&quot;&gt;util&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-modifier&quot;&gt;Arrays&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment&quot;&gt;&#x2F;&#x2F;&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment&quot;&gt; create the unsorted array of countries here&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-variable&quot;&gt;Arrays&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;sort&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;countries&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment&quot;&gt;&#x2F;&#x2F;&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment&quot;&gt; the array &amp;quot;countries&amp;quot; is now sorted&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;looping-over-arrays&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#looping-over-arrays&quot; aria-label=&quot;Anchor link for: looping-over-arrays&quot;&gt;Looping over arrays&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;The process of looping through collections like arrays, lists, sets, etc. is also known as &lt;em&gt;iterating&lt;&#x2F;em&gt;. When we &lt;em&gt;iterate&lt;&#x2F;em&gt; over an array, we&#x27;re simply checking the value in each box of the array one by one and usually performing the same actions with each value, unless specified otherwise by some logic control (&lt;code&gt;if-else&lt;&#x2F;code&gt; and such).&lt;&#x2F;p&gt;
&lt;p&gt;There are a few ways to iterate over arrays:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Traditional &lt;code&gt;for&lt;&#x2F;code&gt; loop:&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;java&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-storage z-type&quot;&gt;String&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt; country&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-keyword z-control&quot;&gt;for&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; (&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-type&quot;&gt;int&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt; i&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt; =&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric&quot;&gt; 0&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;span&gt; i &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt; countries&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt;length&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;span&gt; i&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;++&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-keyword z-control&quot;&gt;    if&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; (&lt;&#x2F;span&gt;&lt;span&gt;i &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;!=&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric&quot;&gt; 42&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        country &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt; countries&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;i&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;]&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-variable&quot;&gt;        System&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt;out&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;println&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;country&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation&quot;&gt;    }&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-control&quot;&gt; else&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-variable&quot;&gt;        System&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt;out&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;println&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;            &amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt;The answer to life, the universe &lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;            +&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt;and everything...&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation&quot;&gt;        )&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation&quot;&gt;    }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;for-each&lt;&#x2F;code&gt; loop:&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;java&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-keyword z-control&quot;&gt;for&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; (&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-type&quot;&gt;String&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt; country&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-control&quot;&gt; :&lt;&#x2F;span&gt;&lt;span&gt; countries&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-variable&quot;&gt;    System&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt;out&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;println&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;country&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;while&lt;&#x2F;code&gt; loop:&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;java&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-storage z-type&quot;&gt;int&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt; i&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt; =&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric&quot;&gt; 0&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-storage z-type&quot;&gt;String&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt; country&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-keyword z-control&quot;&gt;while&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; (&lt;&#x2F;span&gt;&lt;span&gt;i &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt; countries&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt;length&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-keyword z-control&quot;&gt;    if&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; (&lt;&#x2F;span&gt;&lt;span&gt;i &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;!=&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric&quot;&gt; 42&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        country &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt; countries&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;i&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;]&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-variable&quot;&gt;        System&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt;out&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;println&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;country&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation&quot;&gt;    }&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-control&quot;&gt; else&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-variable&quot;&gt;        System&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt;out&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;println&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;            &amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt;The answer to life, the universe &lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;            +&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt;and everything...&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation&quot;&gt;        )&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation&quot;&gt;    }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    i&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;++&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;As you can see, while the &lt;code&gt;for-each&lt;&#x2F;code&gt; loop makes life easier for simple iterations, you have slightly less control over things as it doesn&#x27;t give you the index easily. We can, however, mitigate that problem by using a variable to track the index, like in the &lt;code&gt;while&lt;&#x2F;code&gt; loop:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;java&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-storage z-type&quot;&gt;int&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt; i&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt; =&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric&quot;&gt; 0&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-keyword z-control&quot;&gt;for&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; (&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-type&quot;&gt;String&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt; country&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-control&quot;&gt; :&lt;&#x2F;span&gt;&lt;span&gt; countries&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-keyword z-control&quot;&gt;    if&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; (&lt;&#x2F;span&gt;&lt;span&gt;i &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;!=&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric&quot;&gt; 42&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-variable&quot;&gt;        System&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt;out&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;println&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;country&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation&quot;&gt;    }&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-control&quot;&gt; else&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-variable&quot;&gt;        System&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt;out&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;println&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;            &amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt;The answer to life, the universe &lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;            +&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt;and everything...&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation&quot;&gt;        )&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation&quot;&gt;    }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    i&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;++&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Or you could just use the while loop.&lt;&#x2F;p&gt;
&lt;p&gt;However, this kind of &lt;code&gt;for-each&lt;&#x2F;code&gt; loop does have an advantage. The variable &lt;code&gt;country&lt;&#x2F;code&gt; is created and used within the scope of this loop alone, so you can create a variable with the same name outside the scope and use it without conflicts. It can be done in the other loops too, but is much cleaner, easily readable and more efficient this way. Do note that the variable to track index, &lt;code&gt;i&lt;&#x2F;code&gt;, is declared outside the scope of the &lt;code&gt;for-each&lt;&#x2F;code&gt; loop, so make sure to be careful about that later. Next time you want to use it in that scope, you should reset it to &lt;code&gt;0&lt;&#x2F;code&gt; before you perform any operations with it, unless you actually want to retain the value it has after going through the loop.&lt;&#x2F;p&gt;
&lt;p&gt;It&#x27;s often important to choose the correct loop for the task at hand. Take a deep breath, relax and think about which loop might put you at an advantage.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;check-for-identical-arrays&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#check-for-identical-arrays&quot; aria-label=&quot;Anchor link for: check-for-identical-arrays&quot;&gt;Check for identical arrays&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;Now that you&#x27;ve made some arrays, you might want to check if two arrays contain the same things. We could of course make a method to compare two given arrays using loops and &lt;code&gt;if-else&lt;&#x2F;code&gt; control, but that would be too much work. Thus, the &lt;code&gt;Arrays.equals()&lt;&#x2F;code&gt; method will certainly come in handy and take some load off our shoulders.&lt;&#x2F;p&gt;
&lt;p&gt;Here&#x27;s how it works:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;java&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-keyword z-other&quot;&gt;import&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-modifier&quot;&gt; java&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-modifier&quot;&gt;util&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-modifier&quot;&gt;Arrays&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment&quot;&gt;&#x2F;&#x2F;&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment&quot;&gt; make an array, countries&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment&quot;&gt;&#x2F;&#x2F;&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment&quot;&gt; make an array, fruits&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-storage z-type&quot;&gt;boolean&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt; isEqual&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt; =&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt; Arrays&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;equals&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;countries&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; fruits&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-variable&quot;&gt;System&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt;out&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;println&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;isEqual&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment&quot;&gt;&#x2F;&#x2F;&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment&quot;&gt; output: false&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment&quot;&gt;&#x2F;&#x2F;&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment&quot;&gt; output will be &amp;quot;true&amp;quot; if the given arrays are equal&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;helpful-resources&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#helpful-resources&quot; aria-label=&quot;Anchor link for: helpful-resources&quot;&gt;Helpful resources&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;Here are some resources I use to learn Java. I don&#x27;t memorize anything, but rather just look them up when I need to. They&#x27;re all great sites to learn Java (and other languages) and I hope you find them helpful.&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;www.sololearn.com&#x2F;learning&#x2F;1068&quot;&gt;SoloLearn&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;www.geeksforgeeks.org&#x2F;java&#x2F;&quot;&gt;GeeksforGeeks&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;www.w3schools.com&#x2F;java&#x2F;&quot;&gt;W3schools&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;www.tutorialspoint.com&#x2F;java&#x2F;&quot;&gt;tutorialspoint&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;www.javatpoint.com&#x2F;java-tutorial&quot;&gt;Javatpoint&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h2 id=&quot;conclusion&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#conclusion&quot; aria-label=&quot;Anchor link for: conclusion&quot;&gt;Conclusion&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;That&#x27;s all about arrays for now. That should cover the basics of one-dimensional arrays, but do let me know in the comments if I&#x27;ve missed something or made a mistake somewhere.&lt;&#x2F;p&gt;
&lt;p&gt;I hope it was helpful for you. Thanks for reading through. See you later.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>Prefix (++i) vs Postfix (i++) Operators in Code</title>
          <pubDate>Sun, 24 Jan 2021 21:40:48 +0600</pubDate>
          <author>cybardev</author>
          <link>https://cybar.dev/blog/prefix-vs-postfix-increment/</link>
          <guid>https://cybar.dev/blog/prefix-vs-postfix-increment/</guid>
          <description xml:base="https://cybar.dev/blog/prefix-vs-postfix-increment/">&lt;h2 id=&quot;the-dilemma-i-vs-i&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#the-dilemma-i-vs-i&quot; aria-label=&quot;Anchor link for: the-dilemma-i-vs-i&quot;&gt;The dilemma: &lt;code&gt;++i&lt;&#x2F;code&gt; vs &lt;code&gt;i++&lt;&#x2F;code&gt;&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;In C-style languages (C, C++, Java, etc.), the operators &lt;code&gt;++&lt;&#x2F;code&gt; and &lt;code&gt;--&lt;&#x2F;code&gt; are used to add or subtract &lt;code&gt;1&lt;&#x2F;code&gt; from a variable. &lt;code&gt;++&lt;&#x2F;code&gt; is called the “increment” operator, and &lt;code&gt;--&lt;&#x2F;code&gt; is called the “decrement” operator. If the operator is put before the variable, as in &lt;code&gt;++i&lt;&#x2F;code&gt;, it’s called a “prefix” operator. If the operator is put after the variable, as in &lt;code&gt;i--&lt;&#x2F;code&gt;, it’s called a “postfix operator” or “suffix operator”. Here’s a table to help visualize all that:&lt;&#x2F;p&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Operator&lt;&#x2F;th&gt;&lt;th&gt;Name&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;i++&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;td&gt;Postfix increment operator&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;i--&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;td&gt;Postfix decrement operator&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;++i&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;td&gt;Prefix increment operator&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;--i&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;td&gt;Prefix increment operator&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;p&gt;The prefix and postfix operators do the same thing but have different operator precedence compared to the assignment operator. This can lead to your code having unexpected behavior when an increment&#x2F;decrement operator is used in conjunction with the assignment operator. To demonstrate, I’ll show you some examples below.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;standalone-use&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#standalone-use&quot; aria-label=&quot;Anchor link for: standalone-use&quot;&gt;Standalone use&lt;&#x2F;a&gt;&lt;&#x2F;h3&gt;
&lt;ul&gt;
&lt;li&gt;increasing the value of a variable using &lt;code&gt;++&lt;&#x2F;code&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;c&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation&quot;&gt;#&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-control&quot;&gt;include&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt; &amp;lt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt;stdio.h&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-storage z-type&quot;&gt;int&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt; main&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-storage z-type&quot;&gt;    int&lt;&#x2F;span&gt;&lt;span&gt; x &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;=&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric&quot;&gt; 0&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    x&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;++&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;    printf&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-other z-placeholder&quot;&gt;%d&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-character z-escape&quot;&gt;\n&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;,&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call&quot;&gt; x&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-comment&quot;&gt; &#x2F;&#x2F;&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment&quot;&gt; prints 1&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;c&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation&quot;&gt;#&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-control&quot;&gt;include&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt; &amp;lt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt;stdio.h&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-storage z-type&quot;&gt;int&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt; main&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-storage z-type&quot;&gt;    int&lt;&#x2F;span&gt;&lt;span&gt; x &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;=&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric&quot;&gt; 0&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;    ++&lt;&#x2F;span&gt;&lt;span&gt;x&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;    printf&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-other z-placeholder&quot;&gt;%d&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-character z-escape&quot;&gt;\n&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;,&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call&quot;&gt; x&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-comment&quot;&gt; &#x2F;&#x2F;&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment&quot;&gt; prints 1&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;c&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation&quot;&gt;#&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-control&quot;&gt;include&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt; &amp;lt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt;stdio.h&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-storage z-type&quot;&gt;int&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt; main&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-storage z-type&quot;&gt;    int&lt;&#x2F;span&gt;&lt;span&gt; x &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;=&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric&quot;&gt; 0&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    x &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt; x &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;+&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric&quot;&gt; 1&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-comment&quot;&gt; &#x2F;&#x2F;&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment&quot;&gt; or x += 1;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;    printf&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-other z-placeholder&quot;&gt;%d&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-character z-escape&quot;&gt;\n&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;,&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call&quot;&gt; x&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-comment&quot;&gt; &#x2F;&#x2F;&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment&quot;&gt; prints 1&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;The above codes all have the exact same effect: increase the value of &lt;code&gt;x&lt;&#x2F;code&gt; by &lt;code&gt;1&lt;&#x2F;code&gt; and print it. The decrement operator &lt;code&gt;--&lt;&#x2F;code&gt; would have a similar effect. This behavior can be used in while loops to add to a &lt;code&gt;count&lt;&#x2F;code&gt; variable on each iteration.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;use-with-assignment&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#use-with-assignment&quot; aria-label=&quot;Anchor link for: use-with-assignment&quot;&gt;Use with assignment&lt;&#x2F;a&gt;&lt;&#x2F;h3&gt;
&lt;ul&gt;
&lt;li&gt;prefix operator&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;cpp&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation&quot;&gt;#&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-control&quot;&gt;include&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt; &amp;lt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt;stdio.h&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-storage z-type&quot;&gt;int&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt; main&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-storage z-type&quot;&gt;   int&lt;&#x2F;span&gt;&lt;span&gt; x &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;=&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric&quot;&gt; 0&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; y &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;=&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric&quot;&gt; 0&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;   y &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;=&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt; ++&lt;&#x2F;span&gt;&lt;span&gt;x&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;   printf&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-other z-placeholder&quot;&gt;%d&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-character z-escape&quot;&gt;\n&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; x&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-comment&quot;&gt; &#x2F;&#x2F;&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment&quot;&gt; prints 1&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;   printf&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-other z-placeholder&quot;&gt;%d&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-character z-escape&quot;&gt;\n&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; y&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-comment&quot;&gt; &#x2F;&#x2F;&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment&quot;&gt; prints 1&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;cpp&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation&quot;&gt;#&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-control&quot;&gt;include&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt; &amp;lt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt;stdio.h&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-storage z-type&quot;&gt;int&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt; main&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-storage z-type&quot;&gt;   int&lt;&#x2F;span&gt;&lt;span&gt; x &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;=&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric&quot;&gt; 0&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; y &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;=&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric&quot;&gt; 0&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;   x &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt; x &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;+&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric&quot;&gt; 1&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-comment&quot;&gt; &#x2F;&#x2F;&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment&quot;&gt; or x += 1;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;   y &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt; x&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;   printf&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-other z-placeholder&quot;&gt;%d&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-character z-escape&quot;&gt;\n&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; x&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-comment&quot;&gt; &#x2F;&#x2F;&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment&quot;&gt; prints 1&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;   printf&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-other z-placeholder&quot;&gt;%d&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-character z-escape&quot;&gt;\n&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; y&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-comment&quot;&gt; &#x2F;&#x2F;&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment&quot;&gt; prints 1&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;As we can see here, the prefix operator first increases the value of &lt;code&gt;x&lt;&#x2F;code&gt; and returns the new value which is then assigned to &lt;code&gt;y&lt;&#x2F;code&gt; via the assignment operator.&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;postfix operator&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;cpp&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation&quot;&gt;#&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-control&quot;&gt;include&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt; &amp;lt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt;stdio.h&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-storage z-type&quot;&gt;int&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt; main&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-storage z-type&quot;&gt;   int&lt;&#x2F;span&gt;&lt;span&gt; x &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;=&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric&quot;&gt; 0&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; y &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;=&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric&quot;&gt; 0&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;   y &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt; x&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;++&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;   printf&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-other z-placeholder&quot;&gt;%d&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-character z-escape&quot;&gt;\n&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; x&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-comment&quot;&gt; &#x2F;&#x2F;&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment&quot;&gt; prints 1&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;   printf&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-other z-placeholder&quot;&gt;%d&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-character z-escape&quot;&gt;\n&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; y&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-comment&quot;&gt; &#x2F;&#x2F;&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment&quot;&gt; prints 0&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;cpp&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation&quot;&gt;#&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-control&quot;&gt;include&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt; &amp;lt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt;stdio.h&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-storage z-type&quot;&gt;int&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt; main&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-storage z-type&quot;&gt;   int&lt;&#x2F;span&gt;&lt;span&gt; x &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;=&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric&quot;&gt; 0&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; y &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;=&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric&quot;&gt; 0&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;   y &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt; x&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;   x &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt; x &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;+&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric&quot;&gt; 1&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-comment&quot;&gt; &#x2F;&#x2F;&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment&quot;&gt; or x += 1;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;   printf&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-other z-placeholder&quot;&gt;%d&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-character z-escape&quot;&gt;\n&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; x&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-comment&quot;&gt; &#x2F;&#x2F;&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment&quot;&gt; prints 1&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;   printf&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-other z-placeholder&quot;&gt;%d&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-character z-escape&quot;&gt;\n&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; y&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-comment&quot;&gt; &#x2F;&#x2F;&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment&quot;&gt; prints 0&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Here, the postfix operator first returns the current value which is then assigned to &lt;code&gt;y&lt;&#x2F;code&gt; via the assignment operator and then increases the value of &lt;code&gt;x&lt;&#x2F;code&gt;. This works a bit differently than what it looks like. More on that &lt;a href=&quot;https:&#x2F;&#x2F;cybar.dev&#x2F;blog&#x2F;prefix-vs-postfix-increment&#x2F;#a-little-tip&quot;&gt;below&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;use-in-loops&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#use-in-loops&quot; aria-label=&quot;Anchor link for: use-in-loops&quot;&gt;Use in loops&lt;&#x2F;a&gt;&lt;&#x2F;h3&gt;
&lt;p&gt;You’ll be glad to know that in for loops, &lt;code&gt;i++&lt;&#x2F;code&gt; and &lt;code&gt;++i&lt;&#x2F;code&gt; have essentially identical effects. This is because the order of operations in a for loop flows like this:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;c&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-keyword z-control&quot;&gt;for&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; (&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-type&quot;&gt;int&lt;&#x2F;span&gt;&lt;span&gt; i &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;=&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric&quot;&gt; 0&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;span&gt; i &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric&quot;&gt; 5&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt; ++&lt;&#x2F;span&gt;&lt;span&gt;i&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment&quot;&gt;    &#x2F;&#x2F;&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment&quot;&gt; loop body&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;ol&gt;
&lt;li&gt;initialize loop variable &lt;code&gt;i = 0&lt;&#x2F;code&gt; &lt;br &#x2F;&gt;(this is executed &lt;em&gt;once and &lt;strong&gt;only&lt;&#x2F;strong&gt; once&lt;&#x2F;em&gt; before anything else is done with the loop)&lt;&#x2F;li&gt;
&lt;li&gt;check condition &lt;code&gt;i &amp;lt; 5&lt;&#x2F;code&gt;&lt;&#x2F;li&gt;
&lt;li&gt;execute loop body&lt;&#x2F;li&gt;
&lt;li&gt;add &lt;code&gt;1&lt;&#x2F;code&gt; to &lt;code&gt;i&lt;&#x2F;code&gt; in &lt;code&gt;++i&lt;&#x2F;code&gt; or &lt;code&gt;i++&lt;&#x2F;code&gt;&lt;&#x2F;li&gt;
&lt;li&gt;repeat from &lt;code&gt;step 2&lt;&#x2F;code&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;h3 id=&quot;a-little-tip&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#a-little-tip&quot; aria-label=&quot;Anchor link for: a-little-tip&quot;&gt;A little tip&lt;&#x2F;a&gt;&lt;&#x2F;h3&gt;
&lt;p&gt;However, due to the nature of the operators and their precedence explained at the start of this post, &lt;code&gt;++i&lt;&#x2F;code&gt; is considered a slightly better programming practice. This is because &lt;code&gt;i++&lt;&#x2F;code&gt; actually does this:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;save the original value of &lt;code&gt;i&lt;&#x2F;code&gt; to a temporary variable&lt;&#x2F;li&gt;
&lt;li&gt;add &lt;code&gt;1&lt;&#x2F;code&gt; to &lt;code&gt;i&lt;&#x2F;code&gt; (the same as &lt;code&gt;++i&lt;&#x2F;code&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;return the original value of &lt;code&gt;i&lt;&#x2F;code&gt; stored in the temporary variable &lt;br &#x2F;&gt;(&lt;code&gt;++i&lt;&#x2F;code&gt; would return the new value since it doesn’t store the original value in any temporary variable)&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;So, in cases like in the for loop where it doesn’t make a difference in behavior, it just takes up some extra memory and is better avoided. Although, modern compilers are smart enough to catch this and optimize the code to mean the same.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>Welcome to my blog</title>
          <pubDate>Tue, 19 Jan 2021 14:38:01 +0600</pubDate>
          <author>cybardev</author>
          <link>https://cybar.dev/blog/welcome/</link>
          <guid>https://cybar.dev/blog/welcome/</guid>
          <description xml:base="https://cybar.dev/blog/welcome/">&lt;h2 id=&quot;what-s-this-about&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#what-s-this-about&quot; aria-label=&quot;Anchor link for: what-s-this-about&quot;&gt;What&#x27;s this about?&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;Usually it&#x27;s just going to be me and my thoughts. Won&#x27;t be regular, but
I do want to use this as a diary of sorts so might make frequent but short posts
every now and then. I will mostly post about computers and technology since
that is my field of interest. Sometimes I might also post about science and
pop culture.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;who-are-you&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#who-are-you&quot; aria-label=&quot;Anchor link for: who-are-you&quot;&gt;Who are you?&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;An undergrad computer science student from Bangladesh who loves Linux
and all things science and tech.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;what-do-we-have-to-do-with-all-this&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#what-do-we-have-to-do-with-all-this&quot; aria-label=&quot;Anchor link for: what-do-we-have-to-do-with-all-this&quot;&gt;What do we have to do with all this?&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;You could visit the site from time to time and read up some of my posts.
Who knows, you might find something of interest. I might also put
affiliate links in some tech posts. If you purchase anything from the site
following those links (not necessarily the linked product), I will receive a
small comission with no extra cost to you. It&#x27;d be a nice way to show your
kind support.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;strong&gt;Thanks~&lt;&#x2F;strong&gt;&lt;&#x2F;p&gt;
</description>
      </item>
    </channel>
</rss>
