Essay record

Java: Convert Primitive Type int to String

Record
Essay / / 1 min read / 84 words
Tags
Unfiled

DISCLOSURE: Some links may be affiliate links. Details

**Problem: **I have a primitive int that I want to turn into a string

Solution:

Eclipse hates it when you try to pass in a primitive int as a String.  You’ll get warnings if you try to cast it to a string or call .toString() on it.

The easiest way to get around this is to simply concatenate “” at the end.  This’ll allow methods/variables to read the primitive int as a string.

Example:

int aNum = 9;

String bNum = aNum + “”;

Built with CloudSeed Rust