1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Goshia [24]
3 years ago
11

Write a program that removes all spaces from the given input. Ex: If the input is: Hello my name is John. the output is: Hellomy

nameisJohn. Your program must define and call the following method. The method should return a string representing the input string without spaces. public static String removeSpaces (String userString)
Computers and Technology
1 answer:
aleksley [76]3 years ago
3 0

Answer:

public class num2 {

   public static String removeSpaces(String word){

       String wordNoSpaces = word.replaceAll(" ","");

       return wordNoSpaces;

   }

   public static void main(String[] args) {

   String str = "Hello my name is John";

       System.out.println(removeSpaces(str));

   }

}

Explanation:

Using Java Prograamming language

  • Define the method removeSpaces() to accept a string as parameter and return a string as well
  • With the method's body, use Java's built-in method replaceAll() to replace all whitespaces with no spaces String wordNoSpaces = word.replaceAll(" ","");
  • Return the resulting string
  • In the main method define a string with white spaces
  • Call removeSpaces and pass the defined string as an argument
  • Output the result
You might be interested in
A technician wants to move a file called widget.txt from the current directory to /home/fred,
Gala2k [10]

The command that the technician will use to carry out the moving of the file is; Option C; mv widget.txt /home/fred

<h3> Linux Commands</h3>

In Linux, If we want to move files, we make use of the "mv" command which is quite similar to the cp command. The only difference being that with mv command, the file is physically moved from one place to another, whereas with cp, it is being duplicated.

Since the technician wants to move the filled called widget.txt from the current directory to /home/fred, then he will make use of the "mv" command.

Read more about LINUX at; brainly.com/question/25480553

5 0
2 years ago
According to computer analyst Bajarin, 75% of most people’s computer time is spent __________ content.
nalin [4]

Answer:

consuming

Explanation:

5 0
3 years ago
Read 2 more answers
Label some of the main service provided by the internet.using the picture​.. please...
Natasha_Volkova [10]

Answer:

Social media

Laptops

Phones

Emails

Please give brainliest

8 0
3 years ago
Describe how you could obtain a statistical profile of the amount of time spent by a program executing different sections of its
Mazyrski [523]

Answer:

Explanation:

It can be said that the best way to obtain such a statistical profile would be to issue a periodic timer interrupt, then you would simply need to monitor which what code was running when the interruption took place. This information is especially helpful to the programmers as it would allow them to optimize the specific sections of the code that are consuming the most CPU resources, and thus making the overall program more efficient.

7 0
3 years ago
Can we change the format of a field (e.g. Number to Dollars).
mixer [17]

I think the answer is

3 - Usually, but we may need to convert the data types (date to text)

Because we can change the format, but depends of the original format type and in what type you need to format.

I think this can help.

3 0
4 years ago
Other questions:
  • Which of the following is CORRECT about database managementsystem's languages?
    6·1 answer
  • What is the simple way to permanently get rid of an unwanted file
    14·1 answer
  • What is an icon?
    6·1 answer
  • The UNIX system does not attempt to avoid cycles. Instead, it restricts access to the linking capability of the system. Normal u
    11·1 answer
  • What is a google search query that will search for xml files on the domain example.Com
    8·1 answer
  • Match the installation type to its description.
    9·1 answer
  • Is this right? I’m not sure
    15·1 answer
  • Why do I get everything in English?​
    5·2 answers
  • Xavier buys a new laptop for $540. He makes a down payment $75 and pays the rest in 6 equal monthly payments, p. What equation r
    7·1 answer
  • Observe the following statements and decide whether the variable result’s value is TRUE or FALSE.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!