transformer un string en Biginteger java
package com.mkyong;
import java.math.BigInteger;
public class JavaExample {
public static void main(String[] args) {
int n = 100;
System.out.println(n);
// convert int to Integer
Integer integer = Integer.valueOf(n);
System.out.println(integer);
// convert int to BigInteger
BigInteger bigInteger = BigInteger.valueOf(n);
System.out.println(bigInteger);
// convert Integer to BigInteger
//BigInteger bigInteger2 = BigInteger.valueOf(integer); // works
BigInteger bigInteger2 = BigInteger.valueOf(integer.intValue());
System.out.println(bigInteger2);
}
}foo = new String(bi.toByteArray());public BigInteger toBigInteger(String foo)
{
return new BigInteger(foo.getBytes());
}
public String fromBigInteger(BigInteger bar)
{
return new String(bar.toByteArray());
}
package org.arpit.java2blog;
import java.math.BigInteger;
public class StringToBigIntegerMain {
public static void main(String[] args) {
String str="45";
BigInteger bigIntegerStr=new BigInteger(str);
System.out.println("Converted String to BigInteger: "+bigIntegerStr);
}
}
String foo = "some text";
byte[] fooBytes = foo.getBytes();
BigInteger bi = new BigInteger(fooBytes);
Also in Java:
- faire un timer en java
- how to make a copy of an array java
- java for
- getordefault java
- java get current date without time
- stack overflow recyclerview
- capacitor-android. Unfortunately you can't have non-Gradle Java modules and Android-Gradle modules in one project
- raspberry stackexchange how to install the java jdk
- spring framework iterate
- string length in java
- java sort method
- import collections in java
- change color of particular row in jtable
- java localdate subtract two dates
- java get icon for file type
- find the triplet sum in java linked list
- java stream to list
- java scanner input int
- absolute value java
- creating array java
- java convert string with commas to long
- java declare an int inside an if statement
- how to minimize jframe in java
- cordova cannot find symbol import com.google.firebase.iid.FirebaseMessagingService;