last java prob from me for a while

Page 2 - Seeking answers? Join the AnandTech community: where nearly half-a-million members share solutions and discuss the latest tech.

Sureshot324

Diamond Member
Feb 4, 2003
3,370
0
71
Originally posted by: mdchesne
oh, and i'm beginning to loath the Eclipse compiler. my prog compiles fine at the workstations at tech, but i have 50+ errors here at home. lol. i think eclipse is trying too hard

Eclipse is not a compiler, it's an IDE. It just uses the java compiler.
 

emmpee

Golden Member
Nov 26, 2001
1,100
0
0
Originally posted by: mdchesne
I think I'm setting it up wrong. I got it to compile alright, but I don't think the
Well = false
in the Pop method is setting the Well back up in the Main method to false. Still gives me "good" for everthing


That can't/won't work. Primitive types (such as boolean) are passed by value, not by reference. In plain words, changing the value of 'well' in the Pop method will not have any effect outside of the Pop method.
 

mdchesne

Banned
Feb 27, 2005
2,810
1
0
so how would I change the Well in the main class? Is there a way I can put the "if" statement from the Pop method inside the main and avoid all this junk?
 

duragezic

Lifer
Oct 11, 1999
11,234
4
81
Yeah.. your best option would be to have the logic for checking if it is of correct type inside of your main method. Your pop method should just pop and return a reference. You could have it pop anyway, and when it returns the reference, check that reference against type in the main method... even if it turns out to be bad, you can just quit there and say "bad"; it doesn't matter that the stack got popped anyway.
 

mdchesne

Banned
Feb 27, 2005
2,810
1
0
I actually posted another thread in Software and asked for an easier way to ge tthis bracket thing to work. Apparently, simplicity is key (Thanks again MrChad). Yea, he was saying use one stack to find all the openings and pop the closings. I added that if before I pop the first element as soon as a closer was found, I check to make sure the charAt(i)== parens.top() then pop. that means the last opening bracket must be closed first, before any of the others. If it's not equal to, then return an error msg.

http://forums.anandtech.com/messageview...atid=33&threadid=1685408&enterthread=y