code: boolean isValidPackageName(String s) {
          int index;
          while ((index = s.indexOf('.')) != -1) {
              if (!isValidClassName(s.substring(0, index))) return false;
              s = s.substring(index+1);
          }
          return isValidClassName(s);
      }
docs: Is the given string a valid package name?