Saturday, July 16, 2016

Simple utility to convert an int to String

package utilities;
import java.util.Scanner;
public class IntToStr {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("Enter an integer :");
        int num = scanner.nextInt();
        String str = intToStr(num);
        System.out.println("number String : "+str);
    }
    public static String intToStr(Integer num){
        return num.toString();
    }

}

No comments:

Post a Comment