0
What is wrong in the following program?
public class Test { public static void main (String [] args) { nPrintln(5, "Welcome to Java!); } public static void nPrintln (String message, int n) { int n = 1; for ( int i = 0; i<n; i++) System.out.println(message); } }
4 Respuestas
+ 2
Even if this is homework help or something, this is a good excercise for me too, so here goes, hope it helps 😊
1) method nPrintln() parameters defined(String, int) but you call it backwards with (int, String)
2) int n is passed a value of 5, so there's an error/conflict, you can delete "n = 1"
3) missing quote mark" around "Welcome to Java!"
https://code.sololearn.com/c7UjXS0WrsHe/?ref=app
+ 2
Please take note of this little hint:
If you have some questions about your code please use the plus button (+) right above to add your code like will have to do this. It's more easyer to understand and analyse .
Regards kiuziu
+ 1
Thanks Will
0
Thanks