Java Int to String

Sort by

recency

|

819 Discussions

|

  • + 0 comments

    String s = Integer.toString(n);

    Solutions

  • + 0 comments

    The solution without any additional code🧠

    import java.io.*;
    import java.util.*;
    
    public class Solution {
    
        public static void main(String[] args) {
            try (Scanner scanner = new Scanner(System.in)) {
                int n = scanner.nextInt();
                String str = String.valueOf(n);
                
                if (n == Integer.parseInt(str)) {
                    System.out.println("Good job");
                }
            } catch(Exception ex) {
                System.out.println("Wrong answer");
            }
        }
    }
    
  • + 0 comments

    Java code

    convert into a string.

    String s = Integer.toString(n);

  • + 0 comments

    import java.io.; import java.util.;

    public class Solution {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
    
        int n = in.nextInt();
        String s = String.valueOf(n);
        System.out.println("Good job");
    
        in.close();
    }
    

    }

  • + 0 comments

    Java Logic

    String s = String.valueOf(n);