Java 里面的 final 修饰符








public class FinalTest
{





void testInt()
{
System.out.println("test int:");
final int a = 1;
int b = a;
System.out.println(b);
}

void testString()
{
System.out.println("test String:");
final String a = "a";
String b = a;
System.out.println(b);
}

void testInteger()
{
System.out.println("test Integer");
final Integer a = new Integer("1");
Integer b = a;
System.out.println(b);
}

public static void main(String[] args)
{
FinalTest ft = new FinalTest();
ft.testInt();
ft.testString();
ft.testInteger();

int a = ft.A;
int b = FinalTest.B;
System.out.println(a);
System.out.println(b);
}

final int A = 1;
static final int B = 1;
}
// Decompiled by DJ v2.9.9.60 Copyright 2000 Atanas Neshkov  Date: 2007/04/29 21:10:52
// Home Page : http://members.fortunecity.com/neshkov/dj.html - Check often for new version!
// Decompiler options: packimports(3)
// Source File Name: FinalTest.java

import java.io.PrintStream;

public class FinalTest
{

public FinalTest()
{
}

void testInt()
{
System.out.println("test int:");
int i = 1;
System.out.println(i);
}


void testString()
{
System.out.println("test String:");
String s = "a";
System.out.println(s);
}


void testInteger()
{
System.out.println("test Integer");
Integer integer = new Integer("1");
Integer integer1 = integer;
System.out.println(integer1);
}

public static void main(String args[])
{
FinalTest finaltest = new FinalTest();
finaltest.testInt();
finaltest.testString();
finaltest.testInteger();
finaltest.getClass();
int i = 1;
int j = 1;
System.out.println(i);
System.out.println(j);
}

final int A = 1;
static final int B = 1;
}