有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java字符串方法与字符串修改

我有一个程序,我想在空格(…)中填写该程序中缺少的代码 会是什么

package exr3;
public class Exr3 {
    public static void main(String[] args) {
        String str1 ="I like ";
        String str2 ="programming ";
        String str3 ="In Java ";
        String str4;
        System.out.println(str1.length());
        str4= (.......)  ;//*how can concatenate the strings str1, str2, and str3 in str4*
        System.out.println(str4);
        str1= str1.toLowerCase();
        System.out.println(str1);
        System.out.println(....);//* how can returns the index of the first occurrence of the string "Love" in str1*
    } 
}

共 (2) 个答案

  1. # 1 楼答案

    str4 = str1+" "+str2 +" "+str3;
    System.out.println(str4);
    
  2. # 2 楼答案

    对于索引问题。也许你可以试试这个。 System.out.print(str1.indexOf("L"))