Help, I need to return 0. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Help, I need to return 0.

I need to return 0, but my code returns 9 https://code.sololearn.com/ceByuPOAZZLL/?ref=app

2nd Feb 2018, 7:56 AM
Rostislav
Rostislav - avatar
2 Answers
+ 15
public class Program { public static void main(String[] args) { int a = 9; HelloWorld(); a=setToNull(a); /*👉 ☝here is the problem , U forgot to assign value in a☺ */ print(a); } static void HelloWorld(){ System.out.println("Hello World!"); } static int setToNull(int c){ return c = 0; } static void print(int x){ System.out.print(x); } }
2nd Feb 2018, 8:04 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 1
Thank you!
2nd Feb 2018, 5:23 PM
Rostislav
Rostislav - avatar