Java Int to String

Sort by

recency

|

811 Discussions

|

  • + 0 comments

    A simple yet essential concept that comes up often in coding tests! Ekbet Login

  • + 0 comments
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        System.out.println((scan.hasNextInt()) ? ("Good job") : ("Wrong answer"));
        scan.close(); 
    }
    
  • + 0 comments

    This is one of those basic yet essential concepts that often comes up in coding challenges, especially on platforms like HackerRank. Mahadev book

  • + 0 comments

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

    public class Solution {

    public static void main(String[] args) {
    
        int n = 100;
    
        String num = Integer.toString(n);
    
        if(num instanceof String){
            System.out.println("Good job");
        }
        else{
            System.out.println("Wrong answer");
        }
    }
    

    }

  • + 0 comments

    Here is the simple and straight forward approach

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

    public class Solution {

    public static void main(String[] args) {
    
        int n = 100;
    
        String num = "";
    
        num = Integer.toString(n);
    
        if(num instanceof String){
            System.out.println("Good job");
        }
        else{
            System.out.println("Wrong answer");
        }
    }
    

    }