ArrayClass (@NotNull String className) { boolean searchBracket = false; int dims = 0; int pos; for (pos = className.lastIndexOf(']'); pos >= 0; pos--) { char c = className.charAt(pos); if (searchBracket) { if (c == '[') { dims++; searchBracket = false; } else if (!Character.isWhitespace(c)) break; } else { if (c == ']') { searchBracket = true; } else if (!Character.isWhitespace(c)) break; } } if (searchBracket) return null; if (dims == 0) return null; return new ArrayClass(className.substring(0, pos + 1), dims); }