Java Stdin and Stdout II

  • + 2 comments

    here's my solution, its failing in test case 1 and 2 kindly help me understand how can i make it generic public class Solution {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int i = scan.nextInt();
        double d=scan.nextDouble();
        String s= "";
    
    
        // Write your code here.
          while(scan.hasNext())
        {
            s += scan.next();
            s += " ";
        }
        scan.close();
        System.out.println("String: "+s);
        System.out.println("Double: " + d);
        System.out.println("Int: " + i);
    
    }
    

    }