Computer Science, asked by pallabimishra, 6 months ago

write a java statement to input a character from the user through keyboard​

Answers

Answered by ItzVash003
0

Answer:

Accepting keyboard input in Java is done using a Scanner object.

Consider the following statement

  • Scanner.. console = new.. Scanner(System.in)..                                                          This statement declares a reference variable named console. The Scanner object is associated with standard input device (System.in).

  • To get input from keyboard, you can call methods of Scanner class. For example in following statment nextInt() method of Scanner takes an
  • integer and returns to variable x :                                                                                                                                   int x = console.nextInt();                                                                                               EXAMPLE :_Example :import java.util.Scanner;    // Needed for Scanner class/** *  This program demonstrates keyboard input. */public class RectangleArea{   public static void main(String[] args)   {      int length;    // To hold rectangle's length.      int width;     // To hold rectangle's width.      int area;      // To hold rectangle's area      // Create a Scanner object to read input.
Similar questions