public static boolean equalOrContain(String s1,String s2,boolean contain){
  return contain ? s1.contains(s2) : s1.equals(s2);
}

public static boolean equalOrContain ( String s1 , String s2 , boolean contain ) { return contain ? s1 . contains ( s2 ) : s1 . equals ( s2 ) ; }
helper method to make stacksmatch ( ) less messy .
