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"); } } }

4th Oct 2018, 9:58 AM
Nitin Gutte
Nitin Gutte - avatar
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.
4th Oct 2018, 10:22 AM
Anna
Anna - avatar
+ 2
#Anna Thank you...
4th Oct 2018, 11:18 AM
Nitin Gutte
Nitin Gutte - avatar