gpt4 book ai didi

java - 为什么这个转换会出错呢?

转载 作者:行者123 更新时间:2023-12-01 18:03:15 25 4
gpt4 key购买 nike

我在 eclipse 中有这段代码:

        String A = String.valueOf(a);
String B = String.valueOf(b);
String C = String.valueOf(c);
String D = String.valueOf(d);
String E = String.valueOf(e);
String F = String.valueOf(f);
String G = String.valueOf(g);
String H = String.valueOf(h);
String I = String.valueOf(i);
String J = String.valueOf(j);
String K = String.valueOf(k);

String rawpassword = A+B+C+D+E+F+G+H+I+J+K;
int password = Integer.parseInt(rawpassword);
System.out.println(password);

它给了我这个错误

at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:495)
at java.lang.Integer.parseInt(Integer.java:527)
at com.jakibah.codegenerator.Main.Generate(Main.java:65)
at com.jakibah.codegenerator.Main.run(Main.java:24)
at java.lang.Thread.run(Thread.java:745)

但我不明白为什么。有人可以帮助我吗?

最佳答案

    String A = String.valueOf(10);
String B = String.valueOf(10);
String C = String.valueOf(10);
String D = String.valueOf(10);
String E = String.valueOf(10);
String F = String.valueOf(10);
String G = String.valueOf(10);
String H = String.valueOf(10);
String I = String.valueOf(10);
String J = String.valueOf(10);
String K = String.valueOf(10);


String codestring = A+B+C+D+E+F+G+H+I+J+K;
BigInteger bigInteger = new BigInteger(codestring);
System.out.println(bigInteger.max(bigInteger));

关于java - 为什么这个转换会出错呢?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39015785/

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