Answer:
The method to this question can be defined as follows:
Scanner in = new Scanner(. . .);
in.useDelimiter("");
Step-by-step explanation:
Following are the code to the question:
import java.util.*; //import package for user input
public class Main //defining class Main
{
public static void main(String ax[])//defining the main method
{
Scanner in = new Scanner("Database");//crearing Scanner class object that pass value in its parameter
in.useDelimiter(""); //using useDelimiter
System.out.println(in.next()); //use print method to print single character value
}
}
Output:
D
Code explanation:
- In the above code inside the main method scanner class object "in" is created that pass value "Database" in its parameter.
- In the next step, useDelimiter is used that uses the scanner class object and single space n its parameter.
- In the last print, the method is used that prints object value.