Java Int to String

  • + 0 comments

    easy solution. make sure to import java util first

    public class Solution {
    
        public static void main(String[] args) {
            Scanner user = new Scanner(System.in);
            if (user.hasNextInt()) {
                int input = user.nextInt();
                String digits = Integer.toString(input);
                System.out.println("Good job");
            } else {
                System.out.println("Wrong input. Please enter a valid digit.");
            }
            user.close();
        }
    }