<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sarthak sachdeva</title>
    <description>The latest articles on DEV Community by Sarthak sachdeva (@sarthaksachdeva90).</description>
    <link>https://dev.to/sarthaksachdeva90</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2507376%2F553777a6-428e-49db-bc01-b496cc8b771e.png</url>
      <title>DEV Community: Sarthak sachdeva</title>
      <link>https://dev.to/sarthaksachdeva90</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sarthaksachdeva90"/>
    <language>en</language>
    <item>
      <title>Learn List in Java</title>
      <dc:creator>Sarthak sachdeva</dc:creator>
      <pubDate>Tue, 03 Dec 2024 13:48:01 +0000</pubDate>
      <link>https://dev.to/sarthaksachdeva90/what-is-stack-in-dsa-3160</link>
      <guid>https://dev.to/sarthaksachdeva90/what-is-stack-in-dsa-3160</guid>
      <description>&lt;h2&gt;
  
  
  Java List Interface
&lt;/h2&gt;

&lt;p&gt;The List Interface in Java extends the Collection Interface and is a part of java.util package.&lt;/p&gt;

&lt;p&gt;It is used to store the ordered collections of elements. So in a Java List, you can organize and manage the data sequentially.&lt;/p&gt;

&lt;p&gt;Maintained the order of elements &lt;br&gt;
Allows the duplicate elements.&lt;/p&gt;

&lt;p&gt;The implementation classes of the List interface are ArrayList, LinkedList, Stack, and Vector.&lt;/p&gt;

&lt;h2&gt;
  
  
  Can add Null values that depend on the implementation.
&lt;/h2&gt;

&lt;p&gt;Java List – Operations&lt;br&gt;
Since List is an interface, it can be used only with a class that implements this interface. Now, let’s see how to perform a few frequently used operations on the List.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Operation 1: Adding elements to List using add() method&lt;/li&gt;
&lt;li&gt;Operation 2: Updating elements in List using set() method&lt;/li&gt;
&lt;li&gt;Operation 3: Searching for elements using indexOf(), lastIndexOf methods&lt;/li&gt;
&lt;li&gt;Operation 4: Removing elements using remove() method&lt;/li&gt;
&lt;li&gt;Operation 5: Accessing Elements in List using get() method&lt;/li&gt;
&lt;li&gt;Operation 6: Checking if an element is present in the List using contains() method&lt;/li&gt;
&lt;/ol&gt;




&lt;ul&gt;
&lt;li&gt;import list in java from java.util.package;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg3hy4ohbcz2wo62liwki.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg3hy4ohbcz2wo62liwki.png" alt="Image description" width="700" height="388"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create a list object but call List and create object of Arraylist &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff6gb87qykfx0tvppywp0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff6gb87qykfx0tvppywp0.png" alt="Image description" width="800" height="256"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Now add data in list in this list am define a list type is String, so add data as String data .&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmbtdny3a8nxis6ierot2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmbtdny3a8nxis6ierot2.png" alt="Image description" width="800" height="365"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Now run forEach loop in list use keyword is &lt;strong&gt;'for'&lt;/strong&gt; not write &lt;em&gt;forEach&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffifmooij66entjq78fms.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffifmooij66entjq78fms.png" alt="Image description" width="800" height="519"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Now get a specific list data and print.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffn2fegvuhvo6x9nxyqra.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffn2fegvuhvo6x9nxyqra.png" alt="Image description" width="800" height="243"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Now set a data in &lt;strong&gt;list in specific data indexing position&lt;/strong&gt; . it means when i using &lt;strong&gt;set()&lt;/strong&gt; method so they create new data in list with new indexing set &lt;strong&gt;replace the new data with specific index&lt;/strong&gt; which i want ,&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example in list we have a one data like my name ,&lt;br&gt;
list list.add("coder");&lt;br&gt;
so use set() method and replace coder to another data &lt;br&gt;
like : set(0 , "coding"); so 0 is indexing value of coder&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5q8eiacxawyfitzrja4m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5q8eiacxawyfitzrja4m.png" alt="Image description" width="800" height="273"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Now get the size of list ,&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl12z9zuyn2g1m8row251.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl12z9zuyn2g1m8row251.png" alt="Image description" width="800" height="243"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Now remove list element using** remove()** method, &lt;br&gt;
&lt;strong&gt;they remove() method is overloading method,&lt;/strong&gt;&lt;br&gt;
like : &lt;strong&gt;remove(int index)&lt;/strong&gt; , &lt;strong&gt;remove(element)&lt;/strong&gt; &lt;br&gt;
remove by indexing value and remove by actual element&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;REMOVE WIRH INDEX&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9h80dajwetmwcn2vcy0k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9h80dajwetmwcn2vcy0k.png" alt="Image description" width="800" height="406"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;REMOVE WITH ELEMENT&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx9f9aj2g2htihxm9cgyb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx9f9aj2g2htihxm9cgyb.png" alt="Image description" width="800" height="320"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Now find element indexing position &amp;amp;&amp;amp; searching element in list&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk1wi3n8c1qfp48dhaefw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk1wi3n8c1qfp48dhaefw.png" alt="Image description" width="800" height="233"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Adding Elements&lt;br&gt;
In order to add an element to the list, we can use the add() method. This method is overloaded to perform multiple operations based on different parameters.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Updating Elements&lt;br&gt;
After adding the elements, if we wish to change the element, it can be done using the set() method. Since List is indexed, the element which we wish to change is referenced by the index of the element. Therefore, this method takes an index and the updated element which needs to be inserted at that index. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Searching Elements &lt;br&gt;
Searching for elements in the List interface is a common operation in Java programming. The List interface provides several methods to search for elements, such as the indexOf(), lastIndexOf() methods.&lt;br&gt;
Parameters:&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;indexOf(Object o): Returns the index of the first occurrence of the specified element in the list, or -1 if the element is not found&lt;br&gt;&lt;br&gt;
lastIndexOf(Object o): Returns the index of the last occurrence of the specified element in the list, or -1 if the element is not found&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Removing Elements
In order to remove an element from a list, we can use the remove() method. This method is overloaded to perform multiple operations based on different parameters. They are:&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;METHODS TO USE IN LIST&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;-add(int index, element)&lt;br&gt;
-addAll(int index , Collection collection)&lt;br&gt;
-size()&lt;br&gt;
-clear()&lt;br&gt;
-remove(int index)&lt;br&gt;
-remove(element)&lt;br&gt;
-get(int index)&lt;br&gt;
-set(int index , element)&lt;br&gt;
-indexOf(element)&lt;br&gt;
-lastindexOf(element)&lt;br&gt;
-equals(element)&lt;br&gt;
-hashCode()&lt;br&gt;
-isEmpty()&lt;br&gt;
-contain(element)&lt;/p&gt;




&lt;p&gt;this is full code : &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc3n7xt61o5wghg3w9qgl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc3n7xt61o5wghg3w9qgl.png" alt="Image description" width="800" height="1474"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;full code in my github repo checkout : &lt;a href="https://github.com/CreativeCode90/javatopic" rel="noopener noreferrer"&gt;Github&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;checkout my insta account : &lt;a href="https://www.instagram.com/creativecode90/" rel="noopener noreferrer"&gt;insta&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;checkout my medium profile : &lt;a href="https://medium.com/@jcoder967" rel="noopener noreferrer"&gt;medium&lt;/a&gt;&lt;/p&gt;

</description>
      <category>datastructures</category>
      <category>dsa</category>
      <category>java</category>
      <category>programming</category>
    </item>
    <item>
      <title>What is Stack in Dsa.</title>
      <dc:creator>Sarthak sachdeva</dc:creator>
      <pubDate>Mon, 02 Dec 2024 15:30:36 +0000</pubDate>
      <link>https://dev.to/sarthaksachdeva90/what-is-stack-in-dsa-21b1</link>
      <guid>https://dev.to/sarthaksachdeva90/what-is-stack-in-dsa-21b1</guid>
      <description>&lt;p&gt;In Data Structures and Algorithms (DSA), a stack is a linear data structure that operates on the principle of Last In, First Out (LIFO). This means that the last item added to the stack is the first one to be removed. You can think of it like a stack of plates: the last plate placed on top is the first one you take off.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;## Key Operations of a Stack&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Push&lt;/strong&gt;: Adds an element to the top of the stack.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pop&lt;/strong&gt;: Removes and returns the top element from the stack. If the stack is empty, this operation might return an error or exception depending on the implementation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Peek/Top&lt;/strong&gt;: Returns the top element of the stack without removing it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;IsEmpty&lt;/strong&gt;: Checks if the stack is empty.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Size&lt;/strong&gt;: Returns the number of elements in the stack.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;## see Example in image&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6pd8bglnbinn5ud6jztx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6pd8bglnbinn5ud6jztx.png" alt="Image description" width="800" height="485"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvuzi2af7tt3ee4n9prbe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvuzi2af7tt3ee4n9prbe.png" alt="Image description" width="800" height="446"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;in this array we can add elements and we have a fix file of array to store the value according to the size , we have a indexing of each array values .&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F56owph9pxaaqjfweg97z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F56owph9pxaaqjfweg97z.png" alt="Image description" width="700" height="838"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;in this our stack diagram&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;stack is base on &lt;strong&gt;LIFO&lt;/strong&gt; is last in first out .
in stack we have a top element to decide which one is first element &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Array and Stack&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flasoosx4hyj43q1au36h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flasoosx4hyj43q1au36h.png" alt="Image description" width="800" height="353"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;perform pop operation in stack&lt;/strong&gt;&lt;/p&gt;




&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2x9svbq4emxhrrh5eo65.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2x9svbq4emxhrrh5eo65.png" alt="Image description" width="800" height="739"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;when i pop last element to top value is change, top value start from 3&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fznhb9t7nn3yu4h2dkvme.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fznhb9t7nn3yu4h2dkvme.png" alt="Image description" width="596" height="578"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;-- if you to make a stack implementation in java you can see my post about how to implement stack in java&lt;br&gt;
&lt;a href="https://dev.to/sarthaksachdeva90/building-a-stack-implementation-in-java-mastering-data-structure-fundamentals-54b0"&gt;implement stack in java post&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;here github link for code ...&lt;br&gt;
&lt;a href="https://github.com/CreativeCode90/Java_dsa" rel="noopener noreferrer"&gt;github code repo&lt;/a&gt;&lt;/p&gt;

</description>
      <category>datastructures</category>
      <category>dsa</category>
      <category>java</category>
      <category>programming</category>
    </item>
    <item>
      <title>Building a Stack Implementation in Java: Mastering Data Structure Fundamentals.</title>
      <dc:creator>Sarthak sachdeva</dc:creator>
      <pubDate>Mon, 02 Dec 2024 12:43:39 +0000</pubDate>
      <link>https://dev.to/sarthaksachdeva90/building-a-stack-implementation-in-java-mastering-data-structure-fundamentals-54b0</link>
      <guid>https://dev.to/sarthaksachdeva90/building-a-stack-implementation-in-java-mastering-data-structure-fundamentals-54b0</guid>
      <description>&lt;p&gt;*&lt;em&gt;Hey in this code i will make a stack implementation programme *&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;We have a class &lt;strong&gt;"&lt;code&gt;Stack&lt;/code&gt;"&lt;/strong&gt; :&lt;br&gt;
in this class i make a all method for implement stack ,&lt;br&gt;
i using &lt;strong&gt;Integer Array to store Stack Data&lt;/strong&gt;, and in this class we have a some other propertys ,&lt;br&gt;
like : i am define the &lt;strong&gt;Stacksize&lt;/strong&gt; but when i create a object to am &lt;strong&gt;define my new stack size&lt;/strong&gt; , and we have a **indexvalue **of array for where to stack fill data in array and find data and remove  &lt;/p&gt;

&lt;h2&gt;
  
  
  * THIS IS STACK CLASS
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuyqzvnyqu7hgn6ajmgxt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuyqzvnyqu7hgn6ajmgxt.png" alt="Image description" width="800" height="1136"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;in this class we have a some method like&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;public void size() -&amp;gt;  to store the size of stack;&lt;/li&gt;
&lt;li&gt;public void push() -&amp;gt; to push data in stack&lt;/li&gt;
&lt;li&gt;public void pop() -&amp;gt; to remove last element of stack array&lt;/li&gt;
&lt;li&gt;public void remove() -&amp;gt; to remove stack element but give the indexvalue of element which one you want to remove&lt;/li&gt;
&lt;li&gt;public void getStack() -&amp;gt; and get all stack values &lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Methods implement
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiuyo4l8816wf1d3yn6il.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiuyo4l8816wf1d3yn6il.png" alt="Image description" width="800" height="339"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjshp08nc23xiiwxrv4yn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjshp08nc23xiiwxrv4yn.png" alt="Image description" width="800" height="396"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp8msjbl5iw366fw319fn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp8msjbl5iw366fw319fn.png" alt="Image description" width="800" height="388"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0s1ukpj85lp3d3vszgu9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0s1ukpj85lp3d3vszgu9.png" alt="Image description" width="800" height="444"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fosax6am9fak2tv57jxrr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fosax6am9fak2tv57jxrr.png" alt="Image description" width="800" height="418"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvd8dxcxvudzcmleel2kp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvd8dxcxvudzcmleel2kp.png" alt="Image description" width="800" height="330"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  NOW MAKE A OBJECT AND MAKE A STACK
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkpy5aw7jn1pcunqut7cb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkpy5aw7jn1pcunqut7cb.png" alt="Image description" width="800" height="551"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;when an create a object to use stack to am define here my stack size 2 so am set only 2 integer data in stack&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;if you want to code of this stack implementation go to my github repo &lt;br&gt;
&lt;a href="https://github.com/CreativeCode90/Java_dsa" rel="noopener noreferrer"&gt;github&lt;/a&gt;&lt;/p&gt;

</description>
      <category>dsa</category>
      <category>java</category>
      <category>stack</category>
    </item>
    <item>
      <title>What are Generics in java</title>
      <dc:creator>Sarthak sachdeva</dc:creator>
      <pubDate>Sun, 01 Dec 2024 16:27:56 +0000</pubDate>
      <link>https://dev.to/sarthaksachdeva90/what-are-generics-in-java-cgd</link>
      <guid>https://dev.to/sarthaksachdeva90/what-are-generics-in-java-cgd</guid>
      <description>&lt;p&gt;Generics in java that allow to make a classes , methods and interface , that can be operate on any specified type while providing compile time safly , that enable you to write reusable and type-safe code without relying on object and casting , the type parameter is specified within angle-bracket &amp;lt;&amp;gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;We have a some advantage of using Generics&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Type safely&lt;/li&gt;
&lt;li&gt;Code Reusable&lt;/li&gt;
&lt;li&gt;Readability and Maintainability&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;See the Example code .&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj5ty8fsxxomaqxrd8ls7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj5ty8fsxxomaqxrd8ls7.png" alt="Image description" width="800" height="641"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In this Programme we have a Generic class&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;in the class we have a &lt;strong&gt;one variable&lt;/strong&gt;,&lt;br&gt;
and &lt;strong&gt;two method&lt;/strong&gt; and &lt;strong&gt;both method a generic type define&lt;/strong&gt;&lt;br&gt;
in the class am not define any type in variable even both&lt;br&gt;
method and **method parameter **also&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feioapd6ms51luxlgar4w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feioapd6ms51luxlgar4w.png" alt="Image description" width="800" height="337"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;This is our new generic Method outside of class&lt;/strong&gt; &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;this &lt;strong&gt;method work&lt;/strong&gt; is &lt;strong&gt;take a argument&lt;/strong&gt; and &lt;strong&gt;print&lt;/strong&gt; but am not define menully in method parameter &lt;br&gt;
*&lt;em&gt;when method is call then am define there type *&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu7566ayn2p0n0pqe6ubu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu7566ayn2p0n0pqe6ubu.png" alt="Image description" width="800" height="425"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;This Line Of Code use generic class method&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;am create a object of my password class one time ,&lt;br&gt;
and am define my object type is String ,&lt;br&gt;
then am call my generic class method setPass() and set password string type,&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And my generic method also call and print my password from password object &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Same as it is&lt;/strong&gt;&lt;br&gt;
am create my new object of password an pass int type of my object and set int password and print using my generic method&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NOW TALK ABOUT THAT IS  IN JAVA GENERIC&lt;/strong&gt;&lt;br&gt;
so  in java generic is a &lt;strong&gt;TYPE PERAMETER&lt;/strong&gt; or &lt;strong&gt;PLACEHOLDER&lt;/strong&gt;&lt;br&gt;
thar represent a type that will be specified within a generic class , method and interface is used,&lt;br&gt;
it is **not a KEYWORD **but a convention to signify a generic type.&lt;/p&gt;

&lt;p&gt;UNDERSTAND  &lt;br&gt;
role of &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&amp;gt; It allow to create classes , method and interface the can work with a any type in a type manner.

&lt;ul&gt;
&lt;li&gt;&amp;gt; At the time of use (during object creation and method calling )  is replaced with actual type like (String , Integer) .&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;*&lt;em&gt;COMMON CONVERTION TYPE PERAMETERS *&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;T&lt;/strong&gt; -&amp;gt; type (most common use)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;E&lt;/strong&gt; -&amp;gt; Elements (use in collection)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;K&lt;/strong&gt; -&amp;gt; (use in maps)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;V&lt;/strong&gt; -&amp;gt; (use in maps)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;N&lt;/strong&gt; -&amp;gt; numbers&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;S , U , V&lt;/strong&gt; -&amp;gt; multiple types&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>java</category>
      <category>coding</category>
      <category>advancejava</category>
    </item>
  </channel>
</rss>
