Results 1 to 16 of 16
- 05-03-2008, 06:36 AM #1
- 05-03-2008, 02:47 PM #2
What do you mean?freedom exists in the world of ideas
- 05-03-2008, 04:02 PM #3
What I mean is should you be able to search through a stack without having to pop off all the data first.My IP address is 127.0.0.1
- 05-03-2008, 06:45 PM #4
No, that is impossible.... (for me)
But, by using toArray() method, i can search those elements.
How about you?freedom exists in the world of ideas
- 05-03-2008, 07:03 PM #5
You can search through one of Java's stacks with an iterator method because of how Java made their stacks. I believe this breaks down what a stack should be able to do. In a stack you should only be allowed to see the first element, and you should only be able to add or remove to the top of the stack.My IP address is 127.0.0.1
- 05-03-2008, 07:08 PM #6
....Yep....freedom exists in the world of ideas
- 05-03-2008, 07:42 PM #7
This topic as become a topic of debate in the Java community. I was wondering what the opinion of this sites members was. Please don't comment if you don't have anything to add to this discussion, it just makes you look incompetent.My IP address is 127.0.0.1
- 05-04-2008, 05:43 PM #8
Yep means, i agree....
it just makes you look incompetent.
I've learn stack in C and Assembly.
in C, nice and helpful to implement...
in Assembly, i always use stack implementation
(if all general registers are full)
But for Java? i never use that on my application(just on exercises).
Can you show us a serious application that uses a stack? And that application is fully dependent on a stack implementation?
Maybe stack in java will be useful if you will design a new higher level language compiler using java.freedom exists in the world of ideas
- 05-04-2008, 06:43 PM #9
My topic was about the way sun has implemented stacks in their API. A stack should only let the user be able to see the first item int the stack, but Java lets you search through the stack and see whats in the middle of it. An example of this would be a stack calculator. Sorry this isn't the best example, but it works.My IP address is 127.0.0.1
- 05-05-2008, 03:51 AM #10A stack should only let the user be able to see the first item int the stack.
but Java lets you search through the stack and see whats in the middle of it.
And it is for debugging purposes only, other purpose makes the stack abused.freedom exists in the world of ideas
- 05-05-2008, 04:18 AM #11
But you shouldn't need to debug like this. If you are then you have deeper problems with your stack.My IP address is 127.0.0.1
- 05-05-2008, 04:26 AM #12
If i will use an Iterator, then problem may occur if failed to do so.
But by using toArray, it only returns a shadow copy of the stack. Its just to browse the content without banging the element on that stack.(value checking only)
If something is wrong, only push and pop should be and recommended to use.
I don't know the other safe options( if any )freedom exists in the world of ideas
- 05-05-2008, 06:44 AM #13
My 2 cents...
I believe there is a time and place for every idea. Yes stacks allow you to work with the top of the stack always but the main idea behind it is not that. The main idea is to maintain an order for doing something and then undoing it. And stacks are just a solution for this problem.
But then, there are other problems to be solved out there. Sometimes after you build the stack you might need to know some information about it. Sometimes you might need to peek inside and make some decisions. The implementation in Java simply allows the programmer to use a versatile library class as he sees fit.
By the way, there are programming languages out there that use stack manipulation at runtime in order to do optimizations and to offer "magical" features.
Nothing scares me in programming and in life more than a dogma and a religious war :). The only rule is "there are no rules". Don't take a book definition of a fact and make it your "dogma". This will only make you turn a blind eye to other points of view and other possibilities.
Just think about it. Isn't a stack implementation more useful and flexible and possibly a part of the solution for more problems if it allows you to know more about its internal state at any moment? Of course it is also easier to mess up :). But nothing stops you from writing a wrapper that only gives access to the basic stack functionality.Daniel @ [www.littletutorials.com]
Language is froth on the surface of thought
- 05-05-2008, 07:01 AM #14
I agree with you daniel also I just haven't thought of anytime when it would be useful to know whats in the stack. If I have to know then maybe I'm using the wrong thing.My IP address is 127.0.0.1
- 05-05-2008, 08:10 AM #15
As an example just think about two threads:
- thread one is using the stack in a classical way pushing and popping values on the stack
-thread two monitors the stack and it is notified whenever the stack changes; when the stack changes it will go and calculate statistics about the stack content
These two threads use the stack in different ways: one as stack, the other as a list.Daniel @ [www.littletutorials.com]
Language is froth on the surface of thought
- 05-05-2008, 08:16 AM #16
- By ravian in forum New To JavaReplies: 7Last Post: 11-28-2007, 09:53 AM
- By carl in forum New To JavaReplies: 1Last Post: 08-07-2007, 07:05 AM