Java Stdin and Stdout II

Sort by

recency

|

1210 Discussions

|

  • + 1 comment

    For Java15

    import java.util.Scanner;
    
    class Solution
    {
        public static void main(String args[])
        {
            Scanner sc = new Scanner(System.in);
            
            int n = sc.nextInt();
            double d = sc.nextDouble();
            sc.nextLine();
            String s = sc.nextLine();
            
            sc.close();
            
            System.out.println("String: " + s);
            System.out.println("Double: " + d);
            System.out.println("Int: " + n);
        }
    }
    
    • + 0 comments

      whats the need to write sc.nextLine(); before the declaration of string variable even though we are wrting in the string declaration

  • + 0 comments

    solution

  • + 0 comments

    Java might not be the flashiest language, but it gets the job done—rock solid for backend stuff and still super relevant. myfairplay24.in

  • + 0 comments

    Java is a powerful, versatile programming language that has stood the test of time! Skyexchange signup

  • + 1 comment

    import java.util.Scanner;

    public class Solution {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int i = scan.nextInt();
        double d = scan.nextDouble();
        scan.nextLine();
        String s = scan.nextLine();
    
        System.out.println("String: " + s);
        System.out.println("Double: " + d);
        System.out.println("Int: " + i);
    }
    

    }

    • + 0 comments

      this is the right way to solve this question