Liutauras Vilda wrote:1. Why the class isn't public? Methods too?
4. You have some constants: 0 and -1; Why not to define them somewhere at the beginning of the class and use them, so the code would be more professional?
6. Don't import everything from util package. Import classes you are going to use. That can give to somebody and instant clue how you have implemented your stack. Use wildcard imports if you using quite a few classes from a particular package.
Stephan van Hulst wrote:Actually I think this is great style, and the OP should keep it up. Only make things public when they really have to be. This should be a habit for everybody.
Stephan van Hulst wrote:I don't think these will be necessary. The instances where 0 is used should be replaced with a call to an isEmpty() method.
Stephan van Hulst wrote:This advise holds for packages that are not widely used. If you use wildcard import for packages such as java.util, java.io, etc. it actually becomes easier to see what classes are being imported that are NOT commonly used.
Liutauras Vilda wrote:Such project looks like a potential candidate for OP's proprietary API, hence such advice.
Good idea, which I should have got with a bit more thought. I don't not like ArrayDeque; I just think it is the wrong implementation for a stack. I would change line 1 toStephan van Hulst wrote:I don't understand why you would even want to use an array . . .
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |