英语单词 One 个人 1. 人的类别

  以下是 Java 查找英语单词的代码:

  import java.util.Scanner;

  public class WordSearch {

  public static void main(String[] args) {

  Scanner scanner = new Scanner(System.in);

  // 读取要查找的单词

  System.out.print("请输入要查找的英语单词:");

  String word = scanner.nextLine();

  // 读取文章

  System.out.print("请输入文章:");

  String article = scanner.nextLine();

  // 将文章转换为小写,方便查找

  article = article.toLowerCase();

  // 查找单词的出现位置

  int index = article.indexOf(word.toLowerCase());

  // 输出结果

  if (index == -1) {

  System.out.println("文章没有包含要查找的单词。");

  } else {

  System.out.println("要查找的单词在文章中第 " + (index + 1) + " 个字符位置。");

  }

  }

  }