Can anyone help me here? Why doesnt hi 5 doesnt get executed | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can anyone help me here? Why doesnt hi 5 doesnt get executed

https://code.sololearn.com/c2k3Yl0qTrgV/?ref=app

8th Sep 2021, 6:46 PM
Ajoh Pv
Ajoh Pv - avatar
3 Answers
+ 2
public class Program { static int balance = 1500; static void showBalance(){ System.out.println(balance); } static void depositAmount(int addB){ balance += addB; System.out.println(balance); } public static void main(String[] args) { showBalance(); depositAmount(300); } }
8th Sep 2021, 7:43 PM
SoloProg
SoloProg - avatar
+ 2
ref2.depositamount(9); // to execute it "hi 5"
8th Sep 2021, 7:54 PM
SoloProg
SoloProg - avatar
+ 1
Thank you and I wish to correct you I think that was a static method and now the present code is right Thanks for the insights
9th Sep 2021, 1:57 AM
Ajoh Pv
Ajoh Pv - avatar