猿问

请大神帮我这段程序每句都注释一下

public String[] getSentences(){ 

ArrayList<String> set=new ArrayList<String>();  

int length=input.getText().length();

for(int i=0,last=0;i<length;i++){  

String s=String.valueOf(input.getText().charAt(i));   

if(s.equals("\n"))  

last=i+1;   

if(s.equals(".")||s.equals(",")||s.equals("。")||s.equals("。")||s.equals("!")||s.equals("?")||s.equals("?")||s.equals("!")||s.equals(",")){   

set.add(input.getText().substring(last,i)+s);  

last=i+1;  

}  

return set.<String>toArray(new String[set.size()]); 

public String getKeySentences(String[] key,String[] sentences){ 

String result="";

A:  for(int i=0;i<sentences.length;i++){   

for (int k = 0; k < key.length; k++)  

if (sentences[i].contains(key[k].subSequence(0, key[k].length()))) { 

result += sentences[i] + "\n";    

continue A;    

return result; 


诗酒_年华
浏览 1221回答 0
0回答
随时随地看视频慕课网APP

相关分类

Java
我要回答