Code example for Stack

Methods: lastElement, size

0
activityStack.add(activity);
	} 
 
	public Activity currentActivity(){
		Activity activity=activityStack.lastElement();
		return activity;
	} 
	 
	public Activity previousActivity(){
		int size = activityStack.size();
		if(size == 1 || size == 0){
			return currentActivity(); 
		} 
		Activity activity=activityStack.get(size-2);
		return activity;
	} 
 
	public void finishActivity(){ 
		Activity activity=activityStack.lastElement();
		finishActivity(activity);