/* * Created on 18-may-2004 * * To change the template for this generated file go to * Window>Preferences>Java>Code Generation>Code and Comments */ package version16; /** * @author alexander * * To change the template for this generated type comment go to * Window>Preferences>Java>Code Generation>Code and Comments */ public class Test { public static void main(String[] args) { String s; long start = System.currentTimeMillis(); for (int i = 0; i < 1000000; i++) s = "bicho"+i+".gif"; long end = System.currentTimeMillis(); System.out.println("Modo 1 : "+(end-start)); StringBuffer sb; start = System.currentTimeMillis(); for (int i = 0; i < 1000000; i++) { sb = new StringBuffer("bicho"); sb.append(i); sb.append("gif"); s = sb.toString(); } end = System.currentTimeMillis(); System.out.println("Modo 2 : "+(end-start)); String[] frames = {"bicho0.gif","bicho1.gif","bicho2.gif"}; start = System.currentTimeMillis(); for (int i = 0; i < 1000000; i++) { s = frames[i%frames.length]; } end = System.currentTimeMillis(); System.out.println("Modo 3 : "+(end-start)); } }