Java Stdin and Stdout II

Sort by

recency

|

1232 Discussions

|

  • + 2 comments

    For those who curious to know why sc.nextLine( ) used two times

    YT - https://youtu.be/_xqzmDyLWvs

    use this

  • + 1 comment

    We use the nextLine() in the String then only we get the output, It reads the text which was written by us. Code:- 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();
    
        // Write your code here.
    
        System.out.println("String: " + s);
        System.out.println("Double: " + d);
        System.out.println("Int: " + i);
    }
    

    }

  • + 1 comment

    wtf is this bullshit

  • + 1 comment

    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);
    }
    

    }

  • + 1 comment

    For Java15 Platform

    I wrote the code from scratch just to get more practice

    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);
        }
    }