Skip to content

Instantly share code, notes, and snippets.

Created December 9, 2015 01:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/74f6b037583d23e8001b to your computer and use it in GitHub Desktop.
Save anonymous/74f6b037583d23e8001b to your computer and use it in GitHub Desktop.
public class JTestbuild
{
public static void main(String[] args)
{
int i = 0;
while(i < 14)
{
switch(i)
{
case(0):
System.out.print("H");
break;
case(1):
System.out.print("e");
break;
case(2):
System.out.print("l");
break;
case(3):
System.out.print("l");
break;
case(4):
System.out.print("o");
break;
case(5):
System.out.print(",");
break;
case(6):
System.out.print(" ");
break;
case(7):
System.out.print("w");
break;
case(8):
System.out.print("o");
break;
case(9):
System.out.print("r");
break;
case(10):
System.out.print("l");
break;
case(11):
System.out.print("d");
break;
case(12):
System.out.print("!");
break;
case(13):
System.out.print("\n");
break;
}
++i;
}
}
}
@acmadden
Copy link

Can't tell you right now if it's faster, but maybe try String hw = "hello, world"; and then use charAt(i) in the loop. It's shorter and easy to read.

@komfomu
Copy link

komfomu commented Dec 19, 2015

legendary

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment