Java BigInteger Reverse reverse(BigInteger n)

Here you can find the source of reverse(BigInteger n)

Description

reverse

License

Open Source License

Declaration

public static BigInteger reverse(BigInteger n) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.math.BigInteger;

public class Main {
    public static long reverse(long n) {
        String s = String.valueOf(n);
        StringBuilder sb = new StringBuilder(s);
        return Long.valueOf(sb.reverse().toString());
    }//w ww  .ja v a 2  s . c om

    public static BigInteger reverse(BigInteger n) {
        String s = n.toString();
        StringBuilder sb = new StringBuilder(s);
        return new BigInteger(sb.reverse().toString());
    }
}

Related

  1. reverse(BigInteger currentSum)
  2. reverse(BigInteger x, int width)