Should be a straight forward q, | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Should be a straight forward q,

Hi guys. I got the following code: public class JavaApplication3 { /** * @param args the command line arguments */ public static void main(String[] args) { int age = 22; int money = 800; if (age > 18) { if (money > 500) { System.out.println("Welcome"); } } // TODO code application logic here } static void dog(String[] args) { int andrew = 88; if(!(andrew > 31)) { System.out.println("too young"); } else { System.out.println("perfect"); } } } i got no errors on it but simply want it to run the 'dog' method which its completely ignoring. can you help? thanks!

5th Mar 2018, 5:31 PM
Ac1
Ac1 - avatar
3 Answers
+ 14
public class JavaApplication3 { public static void main(String[] args) { int age = 22; int money = 800; if (age > 18) { if (money > 500) { System.out.println("Welcome"); } } dog(); } static void dog() { int andrew = 88; if(!(andrew > 31)) { System.out.println("too young"); } else { System.out.println("perfect"); } } } /*👉 the method dog (String args []) was not working as method call ie dog(a_String_array); in main method was missing*/
5th Mar 2018, 5:34 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
0
Thanks for this mate but I'd tried this, (putting 'dog();) in and instead I got this error: actual and formal arguments list differ in length. therefore what I though I'd do instead of just 'dog()' was insert 'dog(String[] args) but still no luck... all i want to do basically is for one string method to follow another....
6th Mar 2018, 10:37 AM
Ac1
Ac1 - avatar
0
Bo! dude i got it, missing the class. should be: JavaApplication3.dog(args); thanks
6th Mar 2018, 10:59 AM
Ac1
Ac1 - avatar