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.
6 Respuestas
+ 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.
+ 1
sayHelloTo("swali"); //how to call your method
+ 1
wow !!! it worked ..Thanks a lot !!!😊😊😊
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()
}
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
0
Could you write the program and show ..Im getting confused ...
Thanks :)