import java.util.*;
import java.lang.*;
public class Order {
public static String order(String words) {
// ...
/*Enumeration in=words.elements();
while (in.hasMoreElements())
{
// moving cursor to next element
char i =(char)e.nextElement();
if(i=='1'||i==)*/
String[] p= new String[100];
String[] arrOfStr = words.split(" ", 2);
for (String a : arrOfStr)
{
switch()
{
case a.contains("0"):p[0]=a;
break;
case a.contains("1"):p[1]=a;
break;
case a.contains("2"):p[2]=a;
break;
case a.contains("3"):p[3]=a;
break;
case a.contains("4"):p[4]=a;
break;
case a.contains("5"):p[5]=a;
break;
case a.contains("6"):p[6]=a;
break;
case a.contains("7"):p[7]=a;
break;
case a.contains("8"):p[8]=a;
break;
case a.contains("9"):p[9]=a;
break;
}
}
return p;
}
}
i don’t understand what is best suit for this switch case,
i am trying to solve this problem in java,but can’t solve for this switch.
my logic is to check the word of a sentence contains a numbers 0-9 and set the words sequentialy.so i thought switch case may be best for this work.
link of the problem is:https://www.codewars.com/kata/your-order-please/train/java
you can check the problem statement.