Could Someone help me do this? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Could Someone help me do this?

I want to make a code but I'm a beginner to java and don't know what is the problem Code: https://code.sololearn.com/cc1iYZSZx6x1/#java

5th Dec 2019, 1:27 PM
DariusPumma
DariusPumma - avatar
2 Answers
+ 3
The Strings: name1, name2, and name3 are declared within a function. So they are out of scope for where you are trying to print them. The code below might not be set up as you want it, but it will work. If you need any help let me know class MyClass { static void sayHello(String name) { System.out.println("Hello " + name); } static void names(String name) { } public static void main(String[ ] args) { String name1 = ("Darius"); String name2 = ("Daria"); String name3 = ("Karla"); sayHello(name1); sayHello(name2); sayHello(name3); } }
5th Dec 2019, 2:01 PM
Erich Buelow
Erich Buelow - avatar
0
Thanks!! It works!
5th Dec 2019, 3:07 PM
DariusPumma
DariusPumma - avatar