Stack operation

Can we use Stack built in class for problem solving

What is the use of this keyword in stack

Yes we can use built in stack
this keyword can be used for (It cannot be used with static methods):

  1. To get reference of an object through which that method is called within it(instance method).
  2. To avoid field shadowed by a method or constructor parameter.
  3. To invoke constructor of same class.
  4. In case of method overridden, this is used to invoke method of current class.
  5. To make reference to an inner class. e.g ClassName.this
  6. To create an object of inner class e.g enclosingObjectReference.new EnclosedClass