Skip to content

Commit

Permalink
added Stack class in java
Browse files Browse the repository at this point in the history
  • Loading branch information
GauravWalia19 committed Dec 16, 2018
1 parent c37831b commit d8f834a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Java/Data-Structures/STACKS/INBUILT-STACK/Stacks.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import java.util.Stack;
public class Stacks
{
public static void main(String[] args)
{
Stack<Integer> S = new Stack<Integer>();
S.push(1);
S.push(2);
S.push(3);
S.pop();
S.push(4);

System.out.println(S);
System.out.println("size: "+S.size());
System.out.println("empty: "+S.empty());
System.out.println("peek: "+S.peek());
System.out.println("search: "+S.search(1));
}
}
1 change: 1 addition & 0 deletions Java/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
* LINKED STACK
* [Linked Stack](Data-Structures/STACKS/LINKED-STACK/LinkedStack.java)
* INBUILT STACKS
* [Stack class](Data-Structures/STACKS/INBUILT-STACK/Stacks.java)
* MISC STACKS

### :rocket: DYNAMIC PROGRAMMING
Expand Down
1 change: 1 addition & 0 deletions datastructures.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ Indexer for Data Structures Lover
* docs
* implementation
* [C++](C++/Data-Structures/STACKS/stack.cpp)
* [JAVA](Java/Data-Structures/STACKS/INBUILT-STACK/Stacks.java)

#### MISC STACKS

Expand Down

0 comments on commit d8f834a

Please sign in to comment.