200字范文,内容丰富有趣,生活中的好帮手!
200字范文 > java 字数_java 字数统计

java 字数_java 字数统计

时间:2019-05-28 01:26:06

相关推荐

java 字数_java 字数统计

输出:

Word <Java> appeared 4 times in the paragraph.

package cn.CodeSnippet;

import mons.lang3.StringUtils;

public class WordCounter {

public static void main(String[] args) {

// String with our paragraph

String paragraph = "Java Code Geeks (JCGs) is an independent online community focused on creating the"

+ "ultimate Java-to-Java developers resource center; targeted at the technical architect, technical"

+ "team lead (senior developer), project manager and junior developers alike. JCGs serve the Java, "

+ "Scala, Android, SOA, Agile and Telecom communities with daily news written by domain experts, "

+ "articles, tutorials, reviews, announcements, code snippets and open source projects.";

// Declare the word you want to search

String string = "Java";

// Count word repetitions

int counter = StringUtils.countMatches(paragraph, string);

// Print the result

System.out.println("Word <" + string + "> appeared " + counter + " times in the paragraph.");

}

}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。