public class TConst {
  try{
  public static final String cnWenZhangTiMu =
    new String("文章题目 ".getBytes("ISO-8859-1"),"GBK");
   }
  catch(Exception e)
  {
   System.err.println(e.toString());
  }
}

解决方案 »

  1.   

    呵呵.
    你使用的String method 原型如下.
    public String(byte[] bytes,
                  String enc)
           throws UnsupportedEncodingExceptionpublic class UnsupportedEncodingException
    extends IOExceptionIOException 例外属于 checked exception java 语言的例外机制强制要求捕获该类例外,
    当然你可以不处理该例外继续抛出即可.
      

  2.   

    to fft123()
    你的方法能行得通吗?
    这是一个类声明,不是一个方法定义!to chinadfw(爱好)
    我知道要抛出一个异常,可是在哪里抛出呀!
    这只是一个静态常量的声明?
      

  3.   

    public class TConst {
      public static final String cnWenZhangTiMu = init();  private static String init() {
        String str = null;
        try{
          str = new String("文章题目 ".getBytes("ISO-8859-1"),"GBK");
        } catch(Exception e) {
          System.err.println(e.toString());
        }
        return str;
      }
    }