+ 2
Input in java
how do we add an input to a java programme just like "cin" in c++??is there a such an easy way in java?
2 Answers
+ 5
you need to import java.util.scanner package..then...
Scanner sc=new Scanner(System.in);
String text=sc.next();//For taking string as input.
You may use any name instead of sc..
+ 8
For example for integer it could be:
import java.util.Scanner
...
int a = new Scanner(System.in).nextInt();