0

How to obtain output?

static void sayHelloTo(String name) { System.out.println("Hello " + name); } This question is bascially an example in Java chapter "Classes and Objects" subchapter "Method Return Types" in the topic "The Return Type" . can someone please show the output and how to write the program.

6th May 2019, 12:32 PM
swali1
6 Answers
+ 1
your method requiares one parameter name which is of type String, but you call it without any parameters or arguments. In generaly call is eg: someMethod( parameter1, parameter2, parameter3); String are characters within quotes eg "some text" and you need one add in parameter place.
7th May 2019, 2:17 PM
zemiak
+ 1
sayHelloTo("swali"); //how to call your method
8th May 2019, 10:03 AM
zemiak
+ 1
wow !!! it worked ..Thanks a lot !!!😊😊😊
8th May 2019, 10:34 AM
swali1
0
if name is "swali", it outputs "Hello swali" public class Program { public static void main(String[] args) { // here call your method sayHelloTo() } // here write your method sayHelloTo() }
6th May 2019, 5:16 PM
zemiak
0
public class Program { static void sayHelloTo(String name) { System.out.println("Hello " + name); } public static void main(String[] args) { sayHelloTo(); } } this is how I wrote my program above im getting error as displayed below:- ..\Playground\:9: error: method sayHelloTo in class Program cannot be applied to given types; sayHelloTo(); ^ required: String found: no arguments reason: actual and formal argument lists differ in length 1 error
7th May 2019, 11:51 AM
swali1
0
Could you write the program and show ..Im getting confused ... Thanks :)
8th May 2019, 6:43 AM
swali1