0

Why does it give me only first output?

package test_2; public class R5_4 { public static void main(String[] args) { int n = 1; int m = -1; if (n < -m) { System.out.print(n); } else { System.out.print(m); } } public static void main(String[] args) { double x = 0; double y = 1; if (Math.abs(x - y) < 1) { System.out.print(x); } else { System.out.print(y); } } ==================================================== can someone explain to me please?

23rd Jul 2020, 8:45 AM
jjkc
jjkc - avatar
5 Respostas
+ 1
Because main method is already defined above, you will get an error for redefining main method the second time. What are you trying to do that you think of making 2 main methods anyway?
23rd Jul 2020, 8:58 AM
Ipang
+ 1
Choose one of them, can't have two main method definiton in a class.
23rd Jul 2020, 10:27 AM
Ipang
+ 1
Can you explain me what is it exactly that you are trying to do that you think you need to have two main methods? why can't you use conditionals instead?
23rd Jul 2020, 10:35 AM
Ipang
0
How do I make it runs?
23rd Jul 2020, 10:24 AM
jjkc
jjkc - avatar
0
any other ways to run it in one file?
23rd Jul 2020, 10:28 AM
jjkc
jjkc - avatar