Code example for Stack

Methods: lastElement, remove

0
		Activity activity=activityStack.get(size-2);
		return activity;
	} 
 
	public void finishActivity(){ 
		Activity activity=activityStack.lastElement();
		finishActivity(activity);
	} 
 
	public void finishActivity(Activity activity){
		if(activity!=null){
			activityStack.remove(activity);
			activity.finish();
			activity=null;
		} 
	} 
 
	public void finishActivity(Class<?> cls){
		for (Activity activity : activityStack) {
			if(activity.getClass().equals(cls) ){
				finishActivity(activity);