DEFAULT_CAPACITY variable

Why the DEFAULT_CAPACITY instance variable has been made static ?

Hi @Vikas-G-141583313319037,
See we made the variable static becouse it is related with the class . Static variables have the property that they can be called using a object and also using class … So when we have to create a property which is same for all object of a class we create that property static … So here the DEFAULT_CAPACITY is same for all stacks so we created that variable static.

And also just for information purposes we create a variable final when we do not want the value of that variable to change like here we want DEFAULT_CAPACITY to be 10 throughout so we added final keyword.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.