0
Whats wrong in my code?
public class Divisible { public static void main (String args[]) { int num = Integer.parseInt(args[0]); System.out.println("Given number = "+ num); if(num % 5 == 0) { System.out.println(num+"is divisible by 5"); } else { System.out.println(num+"is not divisible by 5"); } } }
2 Réponses
+ 5
I don't see any errors. You just won't be able to run the code in Sololearn because in line 5, you're trying to access the first command line argument. If you run the code in a real console like this:
java Divisible 58
... it should work.
+ 2
#Anna Thank you...