gpt4 book ai didi

java - 在 Java 中改变类型

转载 作者:行者123 更新时间:2023-11-29 06:45:34 27 4
gpt4 key购买 nike

谁能告诉我如何解决第 10 行的问题?

public class TestString {
public static void main(String[] args) {
String[] tahed = new String[10];
String x;
x = tahed[0] = "P";
System.out.println(x);
String nimi = "Paul";
String[] eraldatud = nimi.split(" ");
System.out.println(nimi.charAt(0));
if (x == nimi.charAt(0)) //10
System.out.println("True");
}
}

最佳答案

public class TestString {
public static void main(String[] args) {
String[] tahed = new String[10];
String x;
x = tahed[0] = "P";
System.out.println(x);
String nimi = "Paul";
String[] eraldatud = nimi.split(" ");
System.out.println(nimi.charAt(0));
if (x.equals(Character.toString(nimi.charAt(0))) //10
System.out.println("True");
}
}

关于java - 在 Java 中改变类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5556881/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com