• Register
1 vote


Hey good people, I hope you are doing good. I was trying to write a program where,  given a string name, e.g. "bob", return a greeting of the form "hello bob!". I was surfing over the internet and find this question from one of the websites. This problem is beyond my understanding. I looking forward to you for a solution.

12 7 7
15,250 points

Please log in or register to answer this question.

1 Answer

1 vote


Gavin, we can do it by creating a simple string type method. I hope you already know about java methods well. If not, you should learn, and practice it ASAP. Java is an OOP language, so learning the usages methods and objects is a must in java. It makes our program efficient and multi-functional alongside. 

Let’s write a program that works as like as you want:

public class HelloBob {
    public static void main(String[] args) {
        HelloBob test = new HelloBob();
    public String helloString(String input) {
        return "Hello " + input + "!";

Keep exploring and solving problems.

13 9 6
94,260 points

Related questions

0 votes
1 answer 11 views
Problem: How can I deal with this problem: gradle project sync failed. basic functionality (e.g. editing debugging) will not work properly
asked Apr 1 rakib1 51.5k points
0 votes
1 answer 288 views
Problem : I have written following code so far: Scanner scanit = new Scanner(System.in); String strscan = scanit.nextLine(); int x = strscan.length(); int y = strscan.charAt(x/2); System.out.println(strscan.substring(y, x-1)); Because of some reason when ... arrays and other advanced stuff. If someone can tell me how to resolve this issue in the easiest way possible that would be the great help!
asked Nov 26, 2019 alecxe 7.5k points
0 votes
1 answer 14 views
Problem: I wrote the following Java code, and it returned a time out error. I'm not exactly sure what that means nor why the code doesn't run public int countHi(String str) { int pos = str.indexOf("hi"); int count = 0; while(pos!=-1) { count++; pos = str.substring(pos).indexOf("hi"); } return count; } I know an alternative solution, using a for loop but I really thought this would work too.
asked Apr 25 Humaira ahmed 50.7k points
0 votes
2 answers 1K views
Problem : I am facing following issue need solution return true if the string "cat" and "dog" appear the same number of times in the given string
asked Nov 13, 2019 peterlaw 6.9k points
0 votes
1 answer 206 views
Problem : I am trying to print every string in Reverse Double Character way (e.g. string -> ggnniirrttss) import java.util.Scanner; public class ReverseDoubleCharecters { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.println("Enter ... I get as follows: ss tt rr ii nn gg All double characters are printed on new lines. Anybody has the solution on this?
asked Nov 22, 2019 peterlaw 6.9k points
0 votes
1 answer 37 views
Problem: I am not able to run a Apache Kafka service due to a failure while trying to start a Zookeeper instance. I have downloaded and tried it with all 3 availabe downloads at the official site. (binarys and source) When i try to start zookeeper with ./bin/ ... virtual machine using Ubuntu 16.04 it works. Unfortunatly, all i found regarding this problem, was for Windows. Thank you for any help.
asked Apr 26 sumaiya simi 43.9k points
0 votes
1 answer 11 views
Problem: I just installed the desktop version of pg4admin after having difficulty running it using my prior install. I used the following installing documentation to pull this off. However, when I run the pgadmin4 service, the page gives me the following error: Unauthorized The ... not found in the configuration database. Did I miss anything in the install process? What can I do to fix this issue?
asked Mar 5 ummesalma 29.2k points
0 votes
1 answer 3 views
Problem: What can cause the error "The specified string is not in the form required for an e-mail address"?
asked May 3 salim1 60.6k points
1 vote
2 answers 317 views
Problem : I need solution for bellow GIT error another git process seems to be running in this repository, e.g. an editor opened by 'git commit'.
asked Nov 8, 2019 peterlaw 6.9k points