⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 difference.java

📁 Thinking in Java 习题答案源码打包
💻 JAVA
字号:
// reusing/Difference.java
// TIJ4 Chapter Reusing, Exercise 18, page 265
/* Create a class with a static final field and a final field and demonstrate
 * the difference between the two.
 */
import java.util.*;


class Test
{
	Test()
	{
		System.out.println( "Test()" );
	}
}



public class Difference
{
	private String name;


	public Difference( String s )
	{
		name = s;
	}


	static final Test sft = new Test(); // constant reference address
	private final Test ft = new Test();
	static final String SFS = "static final"; // class constant
	private final String fs = "final";
	private static Random rand = new Random();
	static final int SFI = rand.nextInt(); // class constant
	private final int fi = rand.nextInt();


	public String toString()
	{
		return ( name + ": " + sft + ", " + ft + ", " + SFS + ", " + fs + ", " + SFI + ", " + fi );
	}

	public static void main( String[] args )
	{
		Difference d1 = new Difference( "d1" );
		Difference d2 = new Difference( "d2" );
		Difference d3 = new Difference( "d3" );
		System.out.println( d1 );
		System.out.println( d2 );
		System.out.println( d3 );
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -