0

Can we ask the user to enter the value without using any class Or importing. It does not work for some reason in this app java

Public static void sum(int a, int b)

21st May 2020, 12:25 PM
Anshul Kalmegh
4 Réponses
+ 1
Yeah we can do it
21st May 2020, 2:14 PM
Shahghasi Adil
Shahghasi Adil - avatar
+ 1
public class Program { public static void main(String[] args) { java.util.Scanner readin = new java.util.Scanner(System.in); String readinn = readin.nextLine(); System.out.printf("%s",readinn); } }
21st May 2020, 2:16 PM
Shahghasi Adil
Shahghasi Adil - avatar
+ 1
Anshul Kalmegh let check it
21st May 2020, 2:17 PM
Shahghasi Adil
Shahghasi Adil - avatar
0
You cannot run a java program without a class and a main method. But you can pass arguments from command line to the main() and then convert those entries to a desired type and perform the required operations.
21st May 2020, 1:34 PM
Avinesh
Avinesh - avatar