Here you can find the source of stackPushUnique(Stack s, Object val)
public static void stackPushUnique(Stack s, Object val)
//package com.java2s; //License from project: Creative Commons License import java.util.Stack; public class Main { /** Push a value into a stack if it is not already there */ public static void stackPushUnique(Stack s, Object val) { if (s == null) { return; }//from www . j a v a2 s .c o m int pos = s.indexOf(val); if (pos == -1) { pos = s.size(); s.push(val); } } }