Pages

Thursday, March 20, 2025

Scanner in Java!

 import java.util.*;


public class JavaBasics {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
            // String input = sc.next();
            // System.out.println(input);


            // String name = sc.nextLine();
            // System.out.println(name);

        int number = sc.nextInt();
        System.out.println(number);

        float price = sc.nextFloat();
        System.out.println(price);
    }

}



Practice questions to strengthen this part of concept, it will help a-lot.

No comments:

Post a Comment

remove duplicates from sorted array - two pointer approach (leetcode)

  class Solution {     public int removeDuplicates ( int [] nums ) {         // base case: return if array have no el.         if ( nums...