写一个java程序 要去掉句子中的特定词.用split() 和the indexOf()结果的效果:Please enter the filtering key:dogPlease enter the input sentences:Many people keep animals at home.Cats and dogs are the most popular.Some people keepsna

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/09 05:57:17
写一个java程序 要去掉句子中的特定词.用split() 和the indexOf()结果的效果:Please enter the filtering key:dogPlease enter the input sentences:Many people keep animals at home.Cats and dogs are the most popular.Some people keepsna

写一个java程序 要去掉句子中的特定词.用split() 和the indexOf()结果的效果:Please enter the filtering key:dogPlease enter the input sentences:Many people keep animals at home.Cats and dogs are the most popular.Some people keepsna
写一个java程序 要去掉句子中的特定词.用split() 和the indexOf()
结果的效果:
Please enter the filtering key:dog
Please enter the input sentences:
Many people keep animals at home.Cats and dogs are the most popular.Some people keep
snakes,but this is rare.I like dogs the most.They are really cute.
The filtered sentences:
Many people keep animals at home.
Some people keep snakes,but this is rare.
They are really cute.

写一个java程序 要去掉句子中的特定词.用split() 和the indexOf()结果的效果:Please enter the filtering key:dogPlease enter the input sentences:Many people keep animals at home.Cats and dogs are the most popular.Some people keepsna
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class FilterKeyword {
 /**
  * 
  * @param args
  */
 
 private static String key;
 
 private static String sentences;
 
 private static String[] tempStr;
 public static void main(String[] args) {
  
  BufferedReader inStr = new BufferedReader(new InputStreamReader(System.in));
  System.out.println("Please enter the filtering key: ");
  try {
   key = inStr.readLine();
      System.out.println("Please enter the input sentences: ");
      sentences = inStr.readLine();
  } catch (IOException e) {
   e.printStackTrace();
  }
  System.out.println("The filtered sentences: ");
  //key = "dog";
  //sentences = "Many people keep animals at home. Cats and dogs are the most popular. Some people keep snakes, but this is rare. I like dogs the most. They are really cute.";
  tempStr = sentences.split("[.] ");
  for (String temp : tempStr){
   if(temp.indexOf(key)<=0){
    if (temp.indexOf(".")<=0)
        System.out.println(temp + ".");
    else
     System.out.println(temp);
   }
  }
 }
}

写一个java程序 要去掉句子中的特定词.用split() 和the indexOf()结果的效果:Please enter the filtering key:dogPlease enter the input sentences:Many people keep animals at home.Cats and dogs are the most popular.Some people keepsna 用java程序写出一个程序求3个数中的最大值 java写一个程序统计文件中一篇文章每个词(要中文和英语的都可以的)的个数 请问一个产生随机数的java程序怎么写?要0-50的随机数,边界也要有输出. JAVA中 如何产生一个特定范围的随机数 比如 我要产生一个0 1 2 这三个数中的一个数再比如 我要产生一个 5到26的一个随机数 这些要怎么写 或者产生一个随机数后 怎样取余来达到这么目的 JAVA题目 :随机生成100个1000以内的整数,将这100个整数中的素数找出来并写到一个文本文件中.急 用最简单的JAVA程序来编程 ,容易看的懂的 C语言,根据特定英文输出句子我想写一个简单的对话程序假定我输入 time能不能让程序输出 I don'know这个能用if语句来判断么 输入两个数,然后输入一个运算符,计算出结果输出,这个JAVA程序怎么写 用JAVA写一个程序,求N个不同形状的图形的总面积. 如何编写一个打印50~100随机数的简单的程序用java写 java英文字母排序问题...编写一个程序,当输入不超过60个字符组成的英文文字时,计算机将这个句子 中的字母按英文字典字母顺序重新排列,排列后的单词的长度要与原始句子中的长度 相同.例 用java 编写一个程序,接受用户输入的一段英文文字,统计出其中的字符个数、单词个数和句子的个数.设句子以“.”“!”“?”结束,单词之间利用空格分隔 编写java程序由键盘输入5个整数,将其中的正整数相加,输出最终结果.要完整的java程序, import java.awt.*; import java.awt.event.*; import javax.swing.*;为什么写JAVA程序总是要写上这些东西?可以不写上吗?不写上会怎样? 帮忙看一下,这句英文怎么写?我用java语言编写了一个程序,名字叫myApp,我英文标注一下,证明软件是java编写的,应该是myApp for java 还是myApp by java 还是其他写法? 初学java,写了一个链接Oracle的小程序,运行后报错:java.sql.SQLException:无效的列索引请问这是为什么?附上程序:package connection;import java.sql.*;public class Connectionb { public static final void main(String args[] 求 java java.sql.SQLException:The Network Adapter could not establish the connection我写了一个链接 oracle 的servlet 小程序,报的上面的错 ,然后我再写个测试的 JDBC 程序,都能通过 ,能打印出数据库中的内容,测试 用JAVA语言编写程序19.编写一个译码程序,把一个英语句子译成数字代码.译码规则是以数字 1代替字母 a,数