• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Stack

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My friend suggest to use stack(pop and push concept) in my program and i surf for it and found it is in java.lang.Object. The push method declare as push(Object item). Actually i want to push a string into the stack. But in this method, it used object type as an item. Is is string can be known as object? And how to implement in. The normal java program as declare, define and create is in stack, we do the same way. How?

I really want to understand the flow of concpet in stack rather than use array to save a few string.
 
Ranch Hand
Posts: 1211
Mac IntelliJ IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A String IS an Object, so you can pass it to the method that accepts Object argument.

As for learning about Stacks here you go -
Data+Structures+Stack

and here is alink to Java Collections class Stack documentation -
http://java.sun.com/j2se/1.4.2/docs/api/java/util/Stack.html
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In chapter 11 of David J. Eck's Introduction to Programming Using Java is a pretty good explanation of Stacks (and other data structures).

I seem to recall that Bruno Preiss' free on-line book, Data Structures and Algorithms with Object-Oriented Design Patterns in Java, was worth reading, as well.
 
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I used Data Structures and Algorithm Analysis in Java of Mark Allen Weiss, when I was in the university... It got a second edition in 2002 as well... The book is really easy to understand Data Structures; including Stack, Queue and other ADTs...

I rate it as 9 out of 10 horseshoes...

Hope it helps...
 
Do the next thing next. That’s a pretty good rule. Read the tiny ad, that’s a pretty good rule, too.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic