Computer Science, asked by deependra6h, 10 months ago

plz give 1 Java programming by using scanner with questions I mark better answer as a brainlist​

Answers

Answered by anishasa
0

Answer:

Explanation:

The Scanner class is used to get user input, and it is found in the java.util package.To create an object of Scanner class, we usually pass the predefined object System.in...System.in within the round brackets tells Java that this will be System Input i.e. input will be given to the system.

n = s.nextInt(); is used to input the value of an integer variable 'n' from the user...To access the methods nextInt(),nextFloat() etc we are using s.nextInt()..nextInt() is a method of the object s of the Scanner class. The new keyword allocates a space in the memory and initialize the object.

Example:

import java.util.Scanner;

class I1{

 public static void main(String[] args){

   Scanner s1 = new Scanner(System.in);       //syntax

   System.out.println("Enter an integer");

   int a;

   a = s1.nextInt();

   System.out.println("The entered integer is" + n);

 }

}

Similar questions