Class ParenthesisMatcher


  • public class ParenthesisMatcher
    extends Object
    • Constructor Detail

      • ParenthesisMatcher

        public ParenthesisMatcher()
    • Method Detail

      • findMatchingParenthesis

        public static int findMatchingParenthesis​(String str,
                                                  int openParenthesisIndex)
        Computes the position of a matching closing parenthesis given the position of the opening parenthesis
        Parameters:
        str - String in which the parenthesis should be matched
        openParenthesisIndex - index of the parenthesis which should be matched with a closing one
        Returns:
        index of closing parenthesis or -1 if string is empty or contains unmatched parenthesis
      • main

        public static void main​(String[] args)