ehsan_faal
شنبه 18 بهمن 1393, 21:53 عصر
سلام.طبق چیزهایی که راجع به متغیر فاینال خوندم میشه فقط و فقط یه بار مقدار دهیش کرد اما توی کد زیر هر بار که مقدار متغیر فاینال رو عوض کردم، عوض شد، در مورد فاینال چیزی رو اشتباه فهمیدم؟
public class Test {
public static void main(String[] args) {
final short[] b = new short[10];
for (short c : b) {
System.out.print(c + " ");
}
System.out.println(" ");
for (int i = 0; i < b.length; i++) {
b[i] = (short) i;
}
for (short c : b) {
System.out.print(c + " ");
}
System.out.println(" ");
for (int i = 0; i < b.length; i++) {
b[i] = (short) 3;
}
for (short c : b) {
System.out.print(c + " ");
}
System.out.println(" ");
}
static final short[] p = new short[10];
}
public class Test {
public static void main(String[] args) {
final short[] b = new short[10];
for (short c : b) {
System.out.print(c + " ");
}
System.out.println(" ");
for (int i = 0; i < b.length; i++) {
b[i] = (short) i;
}
for (short c : b) {
System.out.print(c + " ");
}
System.out.println(" ");
for (int i = 0; i < b.length; i++) {
b[i] = (short) 3;
}
for (short c : b) {
System.out.print(c + " ");
}
System.out.println(" ");
}
static final short[] p = new short[10];
}