varargslab.java

来自「一步 教你学会java 完成一个完整的SWT系统 是本人学习java」· Java 代码 · 共 37 行

JAVA
37
字号
import java.util.Date;import java.text.MessageFormat;import java.util.*;public class VarArgsLab{	public VarArgsLab() { }	public String formatThis() {		Object[] args = {			"Hurricane",			new Integer( 99 ),							new GregorianCalendar( 1999, 0, 1).getTime(),														 new Double( 10E7 )     };		return MessageFormat.format( "On {2}, a {0} destroyed {1} houses and caused {3} of damage", args );	}	public static void main( String[] args ) {		VarArgsLab v = new VarArgsLab();		System.out.println( "Old Style: " );	   System.out.println( v.formatThis());		System.out.println( "New Style: " );		System.out.println( MessageFormat.format( "On {2}, a {0} destroyed {1} houses and caused {3} of damage",			"Hurricane",			new Integer( 99 ),							new GregorianCalendar( 1999, 0, 1).getTime(),														 new Double( 10E7 ) ) );	}}

⌨️ 快捷键说明

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