Refactoring IntegerStack

Extract method getIndexOfLastElement