<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Christopher | Software Developer on Medium]]></title>
        <description><![CDATA[Stories by Christopher | Software Developer on Medium]]></description>
        <link>https://medium.com/@christopherii_?source=rss-edb1dc29ebbc------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*94tRGIeTYAWO2vmLkt2dcQ.jpeg</url>
            <title>Stories by Christopher | Software Developer on Medium</title>
            <link>https://medium.com/@christopherii_?source=rss-edb1dc29ebbc------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 17:04:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@christopherii_/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Java: Most Repeated Number in an Array using HashMap]]></title>
            <link>https://medium.com/@christopherii_/java-most-repeated-number-in-an-array-using-hashmap-8e91ee3f0c5e?source=rss-edb1dc29ebbc------2</link>
            <guid isPermaLink="false">https://medium.com/p/8e91ee3f0c5e</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Christopher | Software Developer]]></dc:creator>
            <pubDate>Sun, 13 Mar 2022 04:45:06 GMT</pubDate>
            <atom:updated>2022-03-13T04:45:06.050Z</atom:updated>
            <content:encoded><![CDATA[<p>In this post, we will use the <strong><em>HashMap</em></strong> class in Java for finding the most repeated number in a given array of numbers.</p><p>I created this class (<strong><em>HashTableExercise</em></strong>) and declare a static method (<strong><em>mostFrequent</em></strong>) for simplicity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/886/1*aXBS3xzCf-YDVEdrJR7fmA.png" /></figure><p>In the method, I create an instance of a <strong><em>HashMap</em></strong> class. The <strong><em>key</em></strong> and <strong><em>value</em></strong> of the class has a type of integer.</p><p>I loop through the <strong><em>numbers</em></strong> parameter then store some data in the <strong><em>map</em></strong> variable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D2CRoOKbuwSAPnTO4IYo4Q.png" /></figure><p>After storing some data that I need, I declare some variable that will be a container for the most repeated number.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7IbuXauyY5u39oOScd-lPA.png" /></figure><p>The <strong><em>map </em></strong>variable has a method that will return all the entries of it.</p><p>I iterate over all the entry set of the <strong><em>map</em></strong> then compare values to check if the current entry in the iteration is greater than the <strong><em>mostRepeatedEntry</em></strong> value.</p><p>Since the <strong><em>mostRepeatedEntry</em></strong> variable can be null, in the loop, I check first if it is a null value. If it is a null value, the current entry in the iteration can be the <strong><em>mostRepeatedEntry</em></strong>.</p><p>The method returns 0 if the <strong><em>mostRepeatedEntry</em></strong> variable is null, if not, then it return its key.</p><p>The whole method:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TgGhHWVkDGFx-Why-c9igg.png" /></figure><p>Using in the main method:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fHdO8l9DyqQUI_H4PnV0Fg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8e91ee3f0c5e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Java: First Repeated Character in a String]]></title>
            <link>https://medium.com/@christopherii_/java-first-repeated-character-in-a-string-1164be6075b5?source=rss-edb1dc29ebbc------2</link>
            <guid isPermaLink="false">https://medium.com/p/1164be6075b5</guid>
            <category><![CDATA[code]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Christopher | Software Developer]]></dc:creator>
            <pubDate>Sat, 12 Mar 2022 05:39:17 GMT</pubDate>
            <atom:updated>2022-03-12T05:39:17.193Z</atom:updated>
            <content:encoded><![CDATA[<p>In this post, we will use <strong><em>Set</em></strong><em>, a generic class in </em><strong>Java</strong><em>, for finding the first repeated character in a given string.</em></p><p><strong><em>Set</em></strong> is a collection of elements that has no duplication. It don’t allow duplicate values.</p><p>Let’s say we have these values, [1,2,3,3,4,4,5], storing these values in a <strong><em>Set</em></strong> will be converted into [1,2,3,4,5]. It removes the duplication of elements in a given value.</p><p>If you want learn more, this is the <a href="https://docs.oracle.com/javase/8/docs/api/java/util/Set.html">documentation</a>.</p><p>In the code, we will use the <strong><em>HashSet</em></strong> class. It is the implementation class of the <strong><em>Set </em></strong>interface.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WCaTu0hgfbBPOrKYXW_oQg.png" /></figure><p>First, we create an instance of the <strong><em>HashSet</em></strong> class.</p><p>We iterate over the <strong><em>word </em></strong>parameter. For every letter in the <strong><em>word</em></strong>, we check it our <strong><em>set</em></strong> already contains the current letter.</p><p>The method quickly returns the current letter if the <strong><em>set</em></strong> already has that value. After checking the letter, we add it to our <strong><em>set</em></strong>.</p><p>If no repeated characters in the given word, the method returns the standard minimum value of the Character.</p><p>Using in the main method:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9SjhGCGiGj8AtcsI5LvW9w.png" /></figure><p>You can see the results on the output tab of the screenshot above. If you want a specific program, I can help you with that. You are just one message away.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1164be6075b5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Java: First Non-Repeating Character]]></title>
            <link>https://medium.com/@christopherii_/java-first-non-repeating-character-2918dc84fc7?source=rss-edb1dc29ebbc------2</link>
            <guid isPermaLink="false">https://medium.com/p/2918dc84fc7</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Christopher | Software Developer]]></dc:creator>
            <pubDate>Sun, 06 Mar 2022 12:56:07 GMT</pubDate>
            <atom:updated>2022-03-06T12:56:07.713Z</atom:updated>
            <content:encoded><![CDATA[<p>This post is about finding the first character that is not repeating in a given word.</p><p>For example, the given word is “a green apple”, the first non-repeating character is letter “g”.</p><p>To achieve this, we will use the <strong><em>HashMap</em></strong> class in Java.</p><p><strong><em>HashMap</em></strong> consist of key value pairs. It is similar to objects in JavaScript.</p><p>In our example, we will assumed that we need to transform the characters in the given word into lowercase.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*44r7bwBhId1QE5xQieZE9Q.png" /></figure><p>Create an instance of HashMap. The key will be a <strong><em>Character</em></strong>, and the value will be an <strong><em>Integer</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sfaPfaG_uW_w-ze3-5EMCA.png" /></figure><p>Transform the given word in to an array of lowercase characters.</p><p>Iterate over the characters then check if it is an existing key in the Map. If the current character is exists, we increment the value of it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R-GwJkeC4R18-vcWnkXhrQ.png" /></figure><p>Iterate over again in our characters. For every character, we get the value of that character in our map. If the value is equals to one, then we return the current character.</p><p>If there is no non-repeating character, we just return zero.</p><p>The whole class:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7vofEhHimKn2S9tpBUrm9A.png" /></figure><p>Using it in the main method:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Cl3SuTG-fgxSAYLnWS8QnQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2918dc84fc7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Java: Reversing a Queue using Stacks]]></title>
            <link>https://medium.com/@christopherii_/java-reversing-a-queue-using-stacks-5e58fb515526?source=rss-edb1dc29ebbc------2</link>
            <guid isPermaLink="false">https://medium.com/p/5e58fb515526</guid>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[development]]></category>
            <dc:creator><![CDATA[Christopher | Software Developer]]></dc:creator>
            <pubDate>Thu, 03 Mar 2022 13:21:08 GMT</pubDate>
            <atom:updated>2022-03-03T13:21:08.112Z</atom:updated>
            <content:encoded><![CDATA[<p>To understand the Queue, it is simply like a line to the cashier when buying things. Whoever is the first person in the line, he or she will be out of the cashier line.</p><p>In a much shorter words, just remember the first-in-first-out.</p><p>Below are the codes:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/1*MJcB2mJF6CWT7LTCReHQUw.png" /><figcaption>Screenshot for main method</figcaption></figure><p>In this main method, I used an <strong><em>ArrayDeque</em></strong> class and create an instance of it. I added some items in the queue then print it in the terminal.</p><p><strong><em>reverse method</em></strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Po6kPF7q5f7x-2e8VC70yQ.png" /><figcaption>Screenshot for reverse method</figcaption></figure><p>This is our reverse method that has a parameter of queue. I used the Stack class since it is good for reversing objects. After creating an instance of the Stack, I iterate over the queue using while loop.</p><p>Quick note for the remove method of the Queue, it returns the declared generic of the Queue which is integer so the remove method returns an integer. It is the same concept for the pop method of the Stack.</p><p>I provided some comments in the code. Some lines are just self-explanatory so I do not think it would be necessary to write it in this post.</p><p><strong><em>main method</em></strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/908/1*3cqC8kqnnidYgCNA_v5ISw.png" /></figure><p>Again, in the main method, I used the reverse method that we created. I also remove the first item then print the Queue again to prove that it is reversed.</p><p>I hope you have learned something. Feel free to reach me if you want me to code for something.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5e58fb515526" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Java: Using Array to Create a Stack Class]]></title>
            <link>https://medium.com/@christopherii_/java-using-array-to-create-a-stack-class-b8e51f140f5f?source=rss-edb1dc29ebbc------2</link>
            <guid isPermaLink="false">https://medium.com/p/b8e51f140f5f</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Christopher | Software Developer]]></dc:creator>
            <pubDate>Tue, 01 Mar 2022 13:47:20 GMT</pubDate>
            <atom:updated>2022-03-01T13:47:20.803Z</atom:updated>
            <content:encoded><![CDATA[<p>In this post, we will create a <strong><em>Stack</em></strong> class using arrays. If you read my previous post (re: <a href="https://medium.com/@christopherii_/java-stacks-reversing-a-string-859241583116">Java Stacks: Reversing a String</a>), you learned that Stacks are fun and easy to use.</p><p>If you are not familiar working with Arrays, I suggest you study it first before you dive in this post.</p><p>Here is the initialized code:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/628/1*Q30sP9rcMyPsGVI8hato8w.png" /><figcaption>Screenshot for Stack class</figcaption></figure><p>I created the <strong><em>Stack</em></strong> class that has two properties (<strong><em>items</em></strong>, and <strong><em>count</em></strong>). I used an array of integers for simplicity. I initialized the <strong><em>items </em></strong>array in just 5 slots. <br>The <strong><em>count</em></strong> property will be our pointer in the <strong><em>items</em></strong> array so we can track which is the top of our stack.</p><p><strong><em>isFull</em></strong>():</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/1*N4w6885PgU_k-CyaU-Ze4A.png" /><figcaption>Screenshot for isFull method</figcaption></figure><p>This method is a helper method and will be reused in other parts of the code. Basically, it tells us if our <strong><em>count</em></strong> property is equally measured to our items. I declared it private since it does not need to be exposed outside of the class.</p><p><strong><em>push()</em></strong> method:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g9l8OmSQGNcIasH18MEywA.png" /><figcaption>Screenshot for push method</figcaption></figure><p>The <strong><em>push</em></strong> method has an item parameter. First, we check if our items is full. If full, we create a new doubled-size array then transfer the current items into the new array. After transferring, we reassigned it to our <strong><em>items</em></strong> property. I discussed this reassigning of array in my previous post (re: <a href="https://medium.com/@christopherii_/how-to-create-an-array-class-in-java-caee5891aee4">How To Create An Array Class in Java</a>).</p><p><strong><em>isEmpty()</em></strong> method:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/458/1*dq3NHkAbO89bQ3uDQuYT8A.png" /><figcaption>Screenshot for isEmpty method</figcaption></figure><p>The isEmpty method just returns if our <strong><em>count</em></strong> property is zero. This method is also a ‘part-time’ helper method since it is also re-used in some parts of the code.</p><p><strong><em>pop()</em></strong> method:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/864/1*d8hfCJs_rubxYT4bWiPB_A.png" /></figure><p>In the pop method, we firstly check if our the <strong><em>items</em></strong> are empty. If it is empty, it throws an exception. If not, we just return the item based on the counter minus one. Why we use the pre-decrement operator? Because we want to use the decremented value of <strong><em>count</em></strong> before we used it as an expression.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/878/1*oRPtvrrU11PDcQk-zKMeIA.png" /><figcaption>Screenshot for peek method</figcaption></figure><p>The <strong><em>peek</em></strong> method is similar to the pop method but we do not need to decrement the value of <strong><em>count</em></strong>. We just need to return the item based on the <strong><em>count</em></strong> variable minus one.</p><p>Using the Stack class:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*MNPKR2DMZT1hSD6XxqAUnQ.png" /><figcaption>Screenshot of stack class in main method</figcaption></figure><p>As you can see, I used the Stack class and it works perfectly fine. I initialized the class, push some values, then used peek and pop method.</p><p>I did not include how to print the values since it will be a long discussion although it is only two lines of code, it can be complicated and too long to explain in this story. You can message me anytime then I will send it to you.</p><p>I hope you learn something here. Thank you for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b8e51f140f5f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Java Stacks: Reversing a String]]></title>
            <link>https://medium.com/@christopherii_/java-stacks-reversing-a-string-859241583116?source=rss-edb1dc29ebbc------2</link>
            <guid isPermaLink="false">https://medium.com/p/859241583116</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Christopher | Software Developer]]></dc:creator>
            <pubDate>Mon, 28 Feb 2022 13:23:11 GMT</pubDate>
            <atom:updated>2022-02-28T13:23:11.442Z</atom:updated>
            <content:encoded><![CDATA[<p>Working with Stacks is helpful especially when dealing with undo features, reversing, and many more.</p><p>In this post, we are using the Stack class in Java to reverse a string. It is very easy to implement, and experience programmers will also agree to this.</p><p>The stack class in Java is generic so we need to specify what data type are we going to store. In this case, we are going to store a character.</p><p>Why character? Since every word or text contains a character, we will store every character of the word in our <strong><em>Stack</em></strong>. After storing all of the characters, we will pop or remove that character out of our stack and store that in a result container.</p><p>Here is the code:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mGOzRuCEsFZtCzo00OBaxw.png" /><figcaption>Screenshot code for StringHelper class</figcaption></figure><p>I created a <strong><em>StringHelper</em></strong> class and the static method <strong><em>reverse() </em></strong>so we don’t need to create an instance of this class.</p><p>I provided explanations for each line of the code. But you might ask why I used the <strong><em>StringBuilder</em></strong> class in Java.</p><p>The reason for that is because it would not be nice to just use the String class then append each characters.</p><p>Strings are immutable and it will create some memory under the hood again and again each time we append new characters to it. So, if you have some <strong><em>String</em></strong> that needs to be change constantly, you can use the <strong><em>StringBuilder</em></strong> class.</p><p>This is the <strong><em>main</em></strong> method</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/898/1*3pR9PpohgkqTLKB1DI20TA.png" /></figure><p>As you can see, “abcd” is the input text and the result is “dcba”.</p><p>So, if you have your professor or some people that wants you to explain the code, that’s it! I hope you understand and learn something from this post.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=859241583116" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How To Create An Array Class in Java]]></title>
            <link>https://medium.com/@christopherii_/how-to-create-an-array-class-in-java-caee5891aee4?source=rss-edb1dc29ebbc------2</link>
            <guid isPermaLink="false">https://medium.com/p/caee5891aee4</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[algorithms]]></category>
            <dc:creator><![CDATA[Christopher | Software Developer]]></dc:creator>
            <pubDate>Sat, 26 Feb 2022 15:47:53 GMT</pubDate>
            <atom:updated>2022-02-26T15:47:53.935Z</atom:updated>
            <content:encoded><![CDATA[<p>In this post, I created an Array class from scratch in Java. This topic is not a data structure lesson. It is only about how to create an array class.</p><p>I created an Array class with methods such as add(), removeAt, indexOf, and size.</p><p>I assumed the items in the array are integers. The image below is the initialization of the Array class.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z5YpzHDl6Vj1TWHQkO8xsQ.png" /><figcaption>Initialization of Array Class</figcaption></figure><p>The properties are pretty self explanatory. I created a constructor since by default, arrays in Java needs to be initialized with a length.</p><p><strong><em>print() method</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/634/1*Gzj6Odmb_1sHKXvFn_v2PQ.png" /><figcaption>Screenshot for print() method</figcaption></figure><p>This <strong><em>print()</em></strong> method is just for printing items in the console. As you can see, I used the <strong><em>count</em></strong> variable for iterating over the items.</p><p><strong>add() method</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g-fE8J_VIMSZ6zlEIB65JQ.png" /><figcaption>Screenshot for add() method</figcaption></figure><p>This <strong><em>add() </em></strong>method has a value parameter. Before we insert the value into the items, we expand it if the items are full.</p><p>First, we check if the current count is equals to our items length. If full, we create another items doubled to its size. Then we copy the old items to the new items.</p><p>If it is all set and done, we add the item in our items array. We increment the count after we add the item.</p><p><strong><em>removeAt() method</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*drdc5HrqRAOzV377uHFVsw.png" /><figcaption>Screenshot for removeAt method</figcaption></figure><p>In the removeAt method, it has an <strong><em>index </em></strong>parameter and it will be used for removing an item based on its index.</p><p>First, we validate the index by throwing an IllegalArgumentException() when the index is less than 0 or greater than the <strong><em>count.</em></strong></p><p>Then, we shift the items to the left since removing an item will create a ‘hole’. After the shifting, we decrement the <strong><em>count</em></strong> property.</p><p>You might ask why we need to subtract one from the count. Since we are ‘shifting’ items to the left, the <strong><em>item[i + 1]</em></strong> might be out of bounds and would throw <strong><em>ArrayIndexOutOfBoundsException. </em></strong>To prevent that from happening, we subtract 1 from the count.</p><p><strong><em>indexOf() method</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/1*yTAN0euG3Ngq39WgtQls6g.png" /><figcaption>Screenshot for indexOf method</figcaption></figure><p>In the <strong><em>indexOf</em></strong> method, we iterate over our <strong><em>items</em></strong> then check to see if the current item in the iteration is equals to the <strong><em>item</em></strong> <strong><em>parameter</em></strong>.</p><p>It returns the <strong><em>i </em></strong>or <strong><em>the current iteration number</em></strong> if found.</p><p>If not, it returns <strong><em>-1</em></strong>.</p><p><strong><em>size() method</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/352/1*GGlUaQRKX1g4N6DoEZpLDA.png" /><figcaption>Screenshot for size method</figcaption></figure><p>Remember the <strong><em>count </em></strong>property we had? The <strong><em>size </em></strong>property is useful because we don’t need to iterate over the items then store the count number in a variable.</p><p>Overall, this is just the basics of creating an Array class from Java. You can extend the class as you like. Thank you for reading this. I hope you learned something. You can message me via <a href="https://twitter.com/christopherii_">Twitter</a>, and <a href="https://www.instagram.com/christopheriilajom/">Instagram</a>. You can also visit my <a href="https://github.com/donchriscorleone">GitHub</a> account.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=caee5891aee4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to create a LinkedList class]]></title>
            <link>https://medium.com/@christopherii_/how-to-create-a-linkedlist-class-aa93ddf82ecb?source=rss-edb1dc29ebbc------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa93ddf82ecb</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Christopher | Software Developer]]></dc:creator>
            <pubDate>Sat, 26 Feb 2022 12:22:48 GMT</pubDate>
            <atom:updated>2022-02-26T12:22:48.770Z</atom:updated>
            <content:encoded><![CDATA[<p>In this post, we will create a LinkedList class from scratch with some methods such as addFirst, addLast, removeFirst, and removeLast.</p><p>A <em>linked list</em> is a type of data structure that connects one object to another object.</p><p>This object also called as <em>node. </em>The <em>node</em> can have properties such as value and another node. In this article, this node looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*gZyy7ialqz4E4rfbjqdRTQ.png" /><figcaption>Image for Node class</figcaption></figure><p>The image above describe our <em>Node </em>class in this article I created. It is a simple class that contains essential properties that can be used in our <em>LinkedList</em> class.</p><p>We can now proceed on creating the <em>LinkedList</em> class.</p><figure><img alt="A screenshot of the initialized LinkedList class" src="https://cdn-images-1.medium.com/max/548/1*LHu2l5V0Y2UTIU38zumFcw.png" /><figcaption>Image of LinkedList class code</figcaption></figure><p>I moved the <em>Node </em>class within the<em> LinkedList </em>class so we don’t need to deal with the complexity of the <em>Node</em> class by accessing its properties.</p><p>In the LinkedList class, we must know what is the first and last node. It is also referred as the <em>head</em> and <em>tail.</em> The size property is used when we want to know the number of nodes in our LinkedList.</p><p>These images below are code screenshot that I wrote. Each line has a comment and some lines are just self explanatory.</p><p>addLast()</p><figure><img alt="A screenshot code for the addLast method" src="https://cdn-images-1.medium.com/max/1024/1*0TldodoaI7mpjd6msJajMg.png" /><figcaption>Image for addLast method</figcaption></figure><p>addFirst()</p><figure><img alt="A screenshot code for the addFirst method" src="https://cdn-images-1.medium.com/max/1024/1*KTq86aU942zp3Y-UTjCyyg.png" /><figcaption>Image for addFirst method</figcaption></figure><p>removeFirst()</p><p><strong><em>NoSuchElementException</em></strong> is the same error thrown in the java.util.LinkedList class when removing an empty list.</p><figure><img alt="A screenshot for removeFirst method" src="https://cdn-images-1.medium.com/max/1024/1*1vbBcGAyf5auP8LWL8Z-Xg.png" /><figcaption>Image for removeFirst method</figcaption></figure><p>removeLast()</p><p>I created a helper function for getting the previous node of a given node. As you can see in the comment, I provided a simple visualization what is the <strong><em>getPrevious() </em></strong>all about. The <strong><em>p</em></strong> represent previous while <strong><em>L</em></strong> represent the last.</p><figure><img alt="A screenshot for removeLast method." src="https://cdn-images-1.medium.com/max/1024/1*xjjw_nbzbJhVLAmiXOGLIQ.png" /><figcaption>Image for removeLast method</figcaption></figure><p>In this helper function, I traversed the list to find the previous node of a given node.</p><figure><img alt="A screenshot for getPrevious method" src="https://cdn-images-1.medium.com/max/1024/1*lebWfSGcGkkujFVZEQCFDQ.png" /><figcaption>Image for getPrevious method</figcaption></figure><p>These are the simple methods for a LinkedList class. It is not complete but I might post it on YouTube for the other methods.</p><p>Thank you for reading. Feel free to message me for improvements.</p><p>My links:</p><p><a href="https://github.com/donchriscorleone">GitHub</a><br><a href="https://www.instagram.com/christopheriilajom/">Instagram</a><br><a href="https://twitter.com/christopherii_">Twitter</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa93ddf82ecb" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>