counter.java:5: package gbk does not exist
import gbk.*;
^
1 error[code]
StringChange.javapackage gbk;public   class   StringChange  {
   public StringChange(){}
   public  static  String  convert(  String  str  )  {
if  (str.trim()==""){
return  null;
}
try  {
/**Encodes  this  String  into  a  sequence  of  bytes  using  the  named   *  charset,  storing  the  result  into  a  new  byte  array.
*/
byte[]  bytesStr=str.getBytes(  "ISO-8859-1"  )  ;
/**Constructs  a  new  String  by  decoding  the  specified  array  of   *  bytes  using  the  specified  charset.  The  length  of  the  new  String   *  is  a  function  of  the  charset,  and  hence  may  not  be  equal  to  
*  the  length  of  the  byte  array.  
*/
return  new  String(  bytesStr,  "GBK"  )  ;  
}
catch(  Exception  ex  )  {
return  str  ;
}
   }
}  Counter.javapackage count;import java.lang.*;
import java.util.*;
import gbk.*;
public class Counter{
    private int count = 0;
    StringChange ITG = new StringChange();
    private String ddd = new String("ComeOnBaby!");
    public Counter(){        
    }
    
    public void setCount(int  i){  
        this.count = i;
    }
    public int getCount(){
        count++;
        return this.count;
    }
    public String getDdd(){
return ddd;
   }
   public void setDdd(String  s ){
        String ss = new String();
ss = ITG.convert(s);
        this.ddd = ss;
   }
}   

解决方案 »

  1.   

    问题解决
    原来是要把gbk文件夹放到count/下不过一点不理解为什么要这样做??希望大家帮忙!
      

  2.   

    楼主不明白包的含义吧.package com.yaray.tools;public class MyTools {
        ...
    }如果你的工程是WEB工程: 需要将MyTools.java编译后的MyTools.class文件放置在WEB-INF/classes/com/yaray/tools目录下
      

  3.   

    你的StringChange 和Counter类在不同的包里
    编译后者时需要把前者的位置添加到classpath而你gbk文件夹放到count下后,因为一般当前目录都被加进classpath,所以可以找到gbk了