求解!

解决方案 »

  1.   

    你可以吧一个String转换成字符数组,然后遍历这个数组,取出每一个字符,再然后用就返回你想要的字符呗...
      

  2.   


    public static char charAt(String str,int index) throws Exception{
            char[] value = str.toCharArray();
            if(index>=0&&index<str.length()){
                return value[index];
            }
            else
                throw new Exception("Argument Error");
        }
      

  3.   

    我也没有太看清楚lz是什么意思~
    lz不妨说的明白点 ~
      

  4.   


    public class CsdnTest {    private final int value[];    private final int offset;    private final int count;
        public CsdnTest(int[] value) {
         this.offset = 0;
         this.count = value.length;
         this.value = value;
            }
        public int intAt(int index) {
            if ((index < 0) || (index >= count)) {
                throw new RuntimeException("超出数组范围!");
            }
            return value[index + offset];
        }

    public static void main(String[] args) {
    int[] value = {0,1,2,3,4,5};
    CsdnTest test = new CsdnTest(value);
    System.out.println(test.intAt(1));
    System.out.println(test.intAt(5));
    System.out.println(test.intAt(6));
    }}
      

  5.   

    LZ的意思要重写下String里的
    char charAt(int index) 
              返回指定索引处的 char 值。 
    方法。3楼以出答案。