帮我分析一java 静态个方法

来源:百度知道 编辑:UC知道 时间:2024/05/22 15:59:45
public static int getCommand(byte[] bytes){
String command=new String(bytes).trim();
return getCommand(command);
}
public static int getCommand(String command){
int comm=0;
int start=command.indexOf('<');
if(start==0){
int end=command.indexOf('>');
command=command.substring(start+1,end);

if(command.equalsIgnoreCase("login")){
comm=1;
}
if(command.equalsIgnoreCase("list")){
comm=2;
}
if(command.equalsIgnoreCase("get")){
comm=3;
}
if(command.equalsIgnoreCase("help")){
comm=4;
}
if(command.equalsIgnoreCase("quit")){
comm=10;
}
if(command.equalsIgnoreCase("ok")){
comm=101;
}
}
return comm;
}
第一个方法返回什么
为什么要写第二个

第一个方法返回根据Bytes数组生成的String
当然要写第二个,废话

第一个还要调用第二个啊,啊,啊,啊啊

第二个是取子字符串,分析<>中的String,然后得出要调用什么Command