展开全部
import java.util.*;
public class demo1 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String arr = in.nextLine();
System.out.println(demo(arr));
}
public static Map demo (String arr )
{
String[] arrs = arr.split(” “);
Map map = new HashMap<>();
List list1 = new LinkedList<>();
List list2 = new LinkedList<>();
List list3 = new LinkedList<>();
List list4 = new LinkedList<>();
for (int i=0;i
if ((arr.charAt(i)>=’a’&&arr.charAt(i)<=’z’)||(arr.charAt(i)>=’A’&&arr.charAt(i)<=’Z’)){
Character character = arr.charAt(i);
list1.add(character.toString());
}
else if (‘0′<=arr.charAt(i)&&’9’>=arr.charAt(i)){
Character character = arr.charAt(i);
list3.add(character.toString());
}
else if (‘ ‘==arr.charAt(i)){
list2.add(” “);
}
else {
Character character = arr.charAt(i);
list4.add(character.toString());
}
}
map.put(“character”,list1);
map.put(“space”,list2);
map.put(“other”,list4);
map.put(“number”,list3);
return map;
}
}
刚刚给你写了一个简单的例子,其e68a843231313335323631343130323136353331333366303739实正则比较方便