Scanner Function In JAVA
Hello Everyone today I am here to you familiar with the most usable word in Java named as Scanner function . Scanner is used in Java to insert a value in the output.
For example:
Scanner sc=new Scanner(System.in);
This statement helps in giving a command only to permit to enter a value in the output window next we have to give a command to enter any char or integer value in the output window.
let's take one more example
import java.util.;
public class basics {
public static void main(String[] args) {
Scanner sc=new Scanner([System.in*](System.in));
after this, you can write
int a=sc.nextInt();
this command helps us to successfully entry of a value in output window.
now we can enter a value in output section to fulfill our requirements.
I will give you the best example related to that
import java.util.;
public class basics {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int a= sc.nextInt();
int b=sc.nextInt();
int sum=a+b;
System.out.println("sum is:"+sum);
}
}*
output is:
Thanks for reading