Java中的charAt

dc20200829發表於2020-12-16
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

class Main {
    public static void main(String[] args) throws IOException {
         //String s1 = "abcdefg".charAt(2);這樣居然報錯....
        //原來charat是把字串—>轉化為字元char型別!
        char a  = "abcdefg".charAt(2);
        System.out.println(a);


    }
}

結果:
c

不是b…