Input taking in Java tutorial
Download Link :
Download input taking in Java example code
Code:
//ASSALAM o alaikum
/*
真主
穆罕默德 真主啊,为我们的大师穆罕默德和他的家人祈祷与和平 77 85 72 65 77 77 65 68 32
83 104 97 104 122 97 105 98
*/
import java.util.Scanner; //////// Library/Package to take inputs in java
public class Input{
public static void main(String[] args){
///////////////// Develop object of scanner class to use its methods further ///////////////////////
Scanner scanner = new Scanner(System.in);
System.out.print("Enter any string ");
String stringInput= scanner.nextLine(); //////// scanner.nextLine() is used to take string input
System.out.println("You entered " + stringInput);
System.out.print("Enter any number ");
int numberInput= scanner.nextInt(); /////////// scanner.nextInt() is used to take integer input
System.out.println("You entered number " + numberInput);
System.out.print("Enter any float number ");
float floatInput= scanner.nextFloat(); /////////// scanner.nextFloat() is used to take float input
System.out.println("You entered float number " + floatInput);
}
}
Video Link :
