文章归档。
1 2 3 4 5 6 7 8 9 10
public class TestString1 { public static void main(String[] args) { // TODO Auto-generated method stub final String[] s1 = {"a","b","c"}; s1[0] = "a1"; System.out.println(s1.length); } }
运行后输出结果
1 编译出错
2 输出 3
final修饰字符串数组,我们知道final在修饰引用数据类型时,就像这里的数组时,能够保证指向该数组地址的引用不能修改,但是数组本身内的值可以被修改。
final
面试客 Blog (cc)
一个有态度的面试的博客.
COMPANY Earth