java - bounded stack implementation -



java - bounded stack implementation -

i'm new java. create bounded stack user can take in constructor how many elements wants in array (stack). stack array of objects. created this:

public class boundedstack { int size; java.lang.object[] list; public boundedstack(int size) { this.size = size; }

it cool if create instance of class boundedstack, array of type object created size of paramater in constructor. (int size).

if user doens't want give in number in constructor , declares instance of class boundedstack. list array should have default value of 32 elements.

something not working on here. have utilize 2 constructors ? 1 parameter , 1 without ? know constructors not hard code...but passin' mind instantiating sizes , array...

does know how can prepare issue ?

yes, 2 constructors. 1 should take size argument; other should take no arguments, , should defer other using this(32); default size of 32.

by way, linkedblockingdeque way of implementing using standard jdk classes.

also, might want alter terminology. capacity word maximum number of elements stack can hold, , size number of elements on stack.

java arrays stack

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -