Skip to content

Instantly share code, notes, and snippets.

@neer2808
Created April 8, 2022 14:25
Show Gist options
  • Save neer2808/877a08b303f2923b36a3c61b4b536608 to your computer and use it in GitHub Desktop.
Save neer2808/877a08b303f2923b36a3c61b4b536608 to your computer and use it in GitHub Desktop.
import java.lang.invoke.SwitchPoint;
public class Test {
public static void main(String[] args) {
String str = "three four eight nine four";
String ans = "";
String strArray[] = str.split(" ");
System.out.println("String : " + str);
for (int i = 0; i < strArray.length; i++) {
switch (strArray[i])
{
case "one":
ans = ans+"1";
break;
case "two":
ans = ans+"2";
break;
case "three":
ans = ans+"3";
break;
case "four":
ans = ans+"4";
break;
case "five":
ans = ans+"5";
break;
case "six":
ans = ans+"6";
break;
case "seven":
ans = ans+"7";
break;
case "eight":
ans = ans+"8";
break;
case "nine":
ans = ans+"9";
break;
case "zero":
ans = ans+"0";
break;
}
}
System.out.println(ans);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment