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

📄 choiceformatexam.java

📁 JavaWeb高级特性书中源代码
💻 JAVA
字号:
import java.text.MessageFormat;
import java.text.ChoiceFormat;
public class ChoiceFormatExam
{
	public static void main(String[] args) throws Exception
	{
		String pattern = "The disk \"{0}\" contains {1}.";
		MessageFormat msgFmt = new MessageFormat(pattern);
		double[] filelimits = {0, 1, 2};
		String[] filepart = {"no files", "one file", "{1,number} files"};
		ChoiceFormat fileform = new ChoiceFormat(filelimits, filepart);
		msgFmt.setFormatByArgumentIndex(1, fileform);
		int fileCount = 100;
		String diskName = "MyDisk";
		Object[] testArgs = {diskName, new Long(fileCount)};
		System.out.println(msgFmt.format(testArgs));
	}
}

⌨️ 快捷键说明

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