Hooray 万岁!

终于有结果了,不用人心惶惶了
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
请设计一个类型,提供如下方法 提示 要统计每个单词出现的次数,由于一个方法不能返回2种类型,我们需要把单词和它的出现次数封装到一个类中 去,所以,可以定义一个类型如下: 由于我们统计的有多个单词,所以,我们上面的 countSize 方法的返回类型就可以设计成 WordBean[],如下: public class PatternDemo { //此方法用来统计 content 中的英文单词个数, 请使用正则表达式来做,单词的正则表达式请自行编写, public int countWords(CharSequence content) { ... } //此方法返回一串固定的字符串,已写好,可以直接用。 public StringBuilder getContent() { //此方法的内容如下: StringBuilder builder = new StringBuilder(); builder.append("Hooray! It's snowing! It's time to make a snowman.James runs out. He makes a big pile of snow. He puts a big snowball on top. He adds a scarf and a hat. He adds an orange for the nose. He adds coal for the eyes and buttons.In the evening, James opens the door. What does he see? The snowman is moving! James invites him in. The snowman has never been inside a house. He says hello to the cat. He plays with paper towels.A moment later, the snowman takes James's hand and goes out.They go up, up, up into the air! They are flying! What a wonderful night!The next morning, James jumps out of bed. He runs to the door.He wants to thank the snowman. But he's gone."); // return builder; } //此方法统计出每个单词[不考虑大小写]出现的次数,数据结构请自行定义,设计如下: public ? countSize(CharSequence content) { //TODO ... } //注:? 处是你需要去思考,该设计什么结构来存放结
最新发布
05-31

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值