bigInteger 可以转换成字符串吗?

Can bigInteger be converted into string?

我可以将大整数值转换为字符串吗?如何?我知道如何将 Int 连接成 double,但不确定是否可以将整数连接成字符串。

这应该可以解决 Java脚本中的问题:

var myString = myBigInt + '';

编辑:原始问题的语言已从 JavaScript 更改为 Java,因此这里是 Java 中的转换方法:

BigInteger myBigInt = 10000000;
String myString = myBigInt.toString();

这是关于 BigInteger.toString() 的教程。

大多数对象,包括 IntegerBigInteger,都可以使用 x.toString() 方法转换为字符串。如果该值可能是 null,您可以使用 String.valueOf(x)"" + x 后者对于机器来说稍微慢一些,但对于开发人员恕我直言,它更快更简单。

最明显的例外是数组,我建议您改用辅助方法 Arrays.toString(array)

not sure if I can concatenate integer into string

您可以使用 + 进行串联。例如

String word = "hello ";
int n = 5;
String text = word + n; // String + int concatenation.

String text = "something";
text += " " + 5;
    package com;
   import java.math.BigInteger;
    public class Test {
    public static void main(String[] args)
    {
    String s=new BigInteger("100").toString();
    System.out.println(s);
    }
    }