JAVA语言:编写一个程序,统计出下列段落中单词的个数.

问题描述:

JAVA语言:编写一个程序,统计出下列段落中单词的个数.
Discover Agile Development Conference & Better Software Conference West—the premier collocated conferences for software professionals.These two events bring you the most up-to-date information,tools,and trends regarding agile,project management,people and teams,software testing and QA,software requirements,process improvement,metrics,design,and architecture.Join industry experts and peers for a week jam-packed with learning sessions that will help you make a powerful impact in your job role and for your company.
1个回答 分类:综合 2014-10-19

问题解答:

我来补答
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Test{
public static void main(String[] args){
String text="Discover Agile Development Conference & Better Software Conference West—the premier collocated conferences for software professionals.These two events bring you the most up-to-date information,tools,and trends regarding agile,project management,people and teams,software testing and QA,software requirements,process improvement,metrics,design,and architecture.Join industry experts and peers for a week jam-packed with learning sessions that will help you make a powerful impact in your job role and for your company.";
Matcher m=Pattern.compile("\\w+").matcher(text);
int c=0;
while(m.find())
System.out.print((++c)+":"+m.group()+"\t");
System.out.println("\n单词数:"+c);
}
}1:Discover 2:Agile 3:Development 4:Conference 5:Better 6:Software 7:Conference 8:West 9:the 10:premier 11:collocated 12:conferences 13:for 14:software 15:professionals 16:These 17:two 18:events 19:bring 20:you 21:the 22:most 23:up 24:to 25:date 26:information 27:tools 28:and 29:trends 30:regarding 31:agile 32:project 33:management 34:people 35:and 36:teams 37:software 38:testing 39:and 40:QA 41:software 42:requirements 43:process 44:improvement 45:metrics 46:design 47:and 48:architecture 49:Join 50:industry 51:experts 52:and 53:peers 54:for 55:a 56:week 57:jam 58:packed 59:with 60:learning 61:sessions 62:that 63:will 64:help 65:you 66:make 67:a 68:powerful 69:impact 70:in 71:your 72:job 73:role 74:and 75:for 76:your 77:company
单词数:77
 
 
展开全文阅读
剩余:2000