tags:

views:

90

answers:

3

hi, im currently learning stacks in java and have a quick question. what will the following code display if the stack is empty? my guess would be "true"?

System.out.println(st.isEmpty());
+2  A: 

Why not run the code and find out?

Casey
Why not post this as a comment?
Felix Kling
It's hard to run the code during the final exam. Mobile phones make very poor development platforms.
jball
+1  A: 

Yes, it will print true.

Running simple snippets of code is very easy (with IDEs like Eclipse - even easier), so you can verify all such assumptions with a few clicks/keystrokes.

Bozho
im having trouble using eclipse, cant seem to find the compile button.
mark
@mark: Then you should read a tutorial. Others managed to use Eclipse, so can you!
Felix Kling
eclipse has a "run" button/menu option. It compiles files automatically (by default)
Bozho
There is no compile button in eclipse (except for the build option in the project menu) The code is compiled automatically every time you save your current file.
Sakin
But it doesn't save the file automatically (last I used it, anyway) so be sure to save first.
Yishai
-1 outright answering a pretty obvious homework/test question.
Bill K
@Bill K it is never said "don't answer easy questions" + I not only answered him, but told him how to answer such questions himself next time.
Bozho
Not so much easy as an obvious test/homework question--I'd hope people could use a little intuition to see that something so trivial is probably being read off a test paper and typed into a phone somewhere.
Bill K
@Bill K - good point about the phone. Will have it in mind hereafter
Bozho
A: 

In the future, give .jpage files a try. They provide a way in Eclipse to run small snippets of code as though they were being interpreted!

dhackner