# Java - toString() Method

## Description

The method is used to get a String object representing the value of the Number Object.

If the method takes a primitive data type as an argument, then the String object representing the primitive data type value is returned.

If the method takes two arguments, then a String representation of the first argument in the radix specified by the second argument will be returned.

## Syntax

Following are all the variants of this method −

```String toString()
static String toString(int i)
```

## Parameters

Here is the detail of parameters −

• i − An int for which string representation would be returned.

## Return Value

• toString() − This returns a String object representing the value of this Integer.

• toString(int i) − This returns a String object representing the specified integer.

## Example

```public class Test {

public static void main(String args[]) {
Integer x = 5;

System.out.println(x.toString());
System.out.println(Integer.toString(12));
}
}
```

This will produce the following result −

```5
12
```
java_numbers.htm
{"ft_lang_label":"__label__en","ft_lang_prob":0.6217395,"math_prob":0.6820124,"size":933,"snap":"2020-45-2020-50","text_gpt3_token_len":183,"char_repetition_ratio":0.16576965,"word_repetition_ratio":0.089655176,"special_character_ratio":0.2165059,"punctuation_ratio":0.1017964,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9874124,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-11-26T10:30:50Z\",\"WARC-Record-ID\":\"<urn:uuid:5f6fb963-a30d-44f2-a09b-f0fe720863d4>\",\"Content-Length\":\"26558\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:8a43f545-bf07-4ad8-ac48-ac8b80d949fa>\",\"WARC-Concurrent-To\":\"<urn:uuid:bf0ef02d-c18b-4b18-88c5-1fbd48ca6eac>\",\"WARC-IP-Address\":\"72.21.91.42\",\"WARC-Target-URI\":\"https://www.tutorialspoint.com/java/number_tostring.htm\",\"WARC-Payload-Digest\":\"sha1:PLPYIRWJNMU6UGCWXIYVLOT34U2EQHQZ\",\"WARC-Block-Digest\":\"sha1:YXTYHWARD3PEXKQKOOYM2K3O6UQZXA3Y\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-50/CC-MAIN-2020-50_segments_1606141187753.32_warc_CC-MAIN-20201126084625-20201126114625-00098.warc.gz\"}"}