Java Int to String

Sort by

recency

|

779 Discussions

|

  • + 0 comments
    Given task it to convert the number to string: I thought Concatination is the easy and best way
         String s=n+"";
    
  • + 0 comments

    extremely poorly worded Problem

  • + 0 comments
    import java.util.Scanner;
    
    public class Solution {
    
        public static void main(String[] args) {
            /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
            Scanner scan = new Scanner(System.in);
            
            try {
                Byte.toString(scan.nextByte());
                System.out.println("Good job");
            }
            catch(Exception e) {
                System.out.println("Wrong answer");
            }
            
            scan.close();
        }
    }
    
  • + 0 comments

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

    public class Solution {

    public static void main(String[] args) {
       Scanner sc = new Scanner(System.in);
       int n = sc.nextInt();
       String s = Integer.toString(n);
       if(n<=100 && n>=-100){
        s=s.valueOf(n);
        System.out.println("Good job");
       }
       else{
        System.out.println("Wrong answer");
       }
    }
    

    }

  • + 0 comments

    I just concatenate the value:

    String s = ""+n;