0

How can I create a stack in java?

Java

16th Dec 2021, 7:21 AM
AYMAN OSMAN
AYMAN OSMAN - avatar
2 odpowiedzi
+ 5
To declare Stack in Java, first, start with keyword stack , followed by angle brackets, <> , that contain the data type of the stack elements. Then write the name of the stack and at last, write the keyword new to allocate memory to the newly created stack. The syntax for declaring a Stack in Java is: <stack> . Ref here: https://www.educative.io/edpresso/how-to-use-the-stack-class-in-java https://www.geeksforgeeks.org/stack-class-in-java/amp/ https://www.javatpoint.com/java-stack
16th Dec 2021, 7:34 AM
NEZ
NEZ - avatar
+ 1
Stack class is available in java util package Otherwise we can create owr own class and methods for stack
16th Dec 2021, 9:34 AM
sree harsha
sree harsha - avatar