## Description

On this document we will be showing a java example on how to use the not() method of BigInteger Class. Basically this method returns a negative value if and only if this BigInteger is non-negative.

## Method Syntax

public BigInteger not()

## Method Argument

Data Type Parameter Description
N/A N/A N/A

## Method Returns

The not() method returns ~this.

## Compatibility

Requires Java 1.1 and up

## Java BigInteger not() Example

Below is a java code demonstrates the use of not() method of BigInteger class. The example presented might be simple however it shows the behavior of the not() method.

```package com.javatutorialhq.java.examples;

import java.math.BigInteger;
import java.util.Scanner;

/*
* A java example source code to demonstrate
* the use of not() method of BigInteger class
*/

public class BigIntegerNotExample {

public static void main(String[] args) {

// get user input
System.out.print("Enter a value:");
Scanner s = new Scanner(System.in);
String input = s.nextLine();
s.close();

// declare a new BigInteger
BigInteger val1 = new BigInteger("-32");
// convert string input to BigInteger
BigInteger val2 = new BigInteger(input);
// get the result value of not() method and print it
System.out.println("Result="+val1.not());
System.out.println("Result="+val2.not());

}

}
```

This example is a lot simpler than it looks. Basically we ask for user input and converted this value into BigInteger. Another BigInteger object were also intialize with constructor having a value of “-32”. We then use the not() method to demonstrate the use of it.

## Sample Output

Below is the sample output when you run the above example. 