import java.util.*;


public class Solution {
    /**
     * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
     *
     * 
     * @param message string字符串 
     * @param keyword string字符串 
     * @return int整型
     */
    public int findKeyword (String message, String keyword) {
        // write code here
      int index = message.indexOf(keyword);
    return index;
}
}

Java。

该题考察的主要知识点包括:

  1. 字符串操作:使用字符串的 indexOf() 方法来查找关键词在信息中的位置。
  2. 条件判断:判断 indexOf() 方法的返回值来确定是否找到关键词。

代码解释:

  1. 使用 indexOf(keyword) 方法在字符串 message 中查找关键词 keyword 第一次出现的位置。
  2. 将找到的位置下标返回作为结果。