fork download
  1.  
  2. /**
  3.   * Returns a string that is a substring of this string. The
  4.   * substring begins at the specified {@code beginIndex} and
  5.   * extends to the character at index {@code endIndex - 1}.
  6.   * Thus the length of the substring is {@code endIndex-beginIndex}.
  7.   * <p>
  8.   * Examples:
  9.   * <blockquote><pre>
  10.   * "hamburger".substring(4, 8) returns "urge"
  11.   * "smiles".substring(1, 5) returns "mile"
  12.   * </pre></blockquote>
  13.   *
  14.   * @param beginIndex the beginning index, inclusive.
  15.   * @param endIndex the ending index, exclusive.
  16.   * @return the specified substring.
  17.   * @exception IndexOutOfBoundsException if the
  18.   * {@code beginIndex} is negative, or
  19.   * {@code endIndex} is larger than the length of
  20.   * this {@code String} object, or
  21.   * {@code beginIndex} is larger than
  22.   * {@code endIndex}.
  23.   */
  24. public String substring(int beginIndex, int endIndex) {
  25. if (beginIndex < 0) {
  26. throw new StringIndexOutOfBoundsException(beginIndex);
  27. }
  28. if (endIndex > value.length) {
  29. throw new StringIndexOutOfBoundsException(endIndex);
  30. }
  31. int subLen = endIndex - beginIndex;
  32. if (subLen < 0) {
  33. }
  34. return ((beginIndex == 0) && (endIndex == value.length)) ? this
  35. : new String(value, beginIndex, subLen);
  36. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:24: error: class, interface, or enum expected
    public String substring(int beginIndex, int endIndex) {
           ^
Main.java:27: error: class, interface, or enum expected
        }
        ^
Main.java:30: error: class, interface, or enum expected
        }
        ^
Main.java:32: error: class, interface, or enum expected
        if (subLen < 0) {
        ^
Main.java:34: error: class, interface, or enum expected
        }
        ^
Main.java:37: error: class, interface, or enum expected
    }
    ^
6 errors
stdout
Standard output is empty