Java - Write code to convert int to String

Requirements

Write code to convert int to String

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        int num = 42;
        System.out.println(int2String(num));
    }/*from   www  .  ja v  a2  s . c om*/

    public static String int2String(int num) {
        try {
            String str = String.valueOf(num);
            return str;
        } catch (Exception e) {
            return "";
        }
    }
}

Related Exercise