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
What is the most common etical rule that must be applied in all technologies​
Sedaia [141]

Explanation:

Personal Privacy: It is an important aspect of ethical issues in information technology

7 0
3 years ago
What type of stone was the most common building material of royal pyramid?
eimsori [14]
I think it's low grade lime stone..
6 0
3 years ago
Which of the following is used to allocate memory for the instance variables of an object of a class?1. the reserved word public
kodGreya [7K]

Answer:

The correct answer to the following question will be 2. the operator new.

Explanation:

New operator is used to allocating the memory to the instance object.The new object can be created by using a "new" keyword in java .

Syntax of using 'new' operator is :

class_name object_name=new class_name() // it allocated the memory to the class

For Example :

ABC obj = new ABC;  

Now, this time obj points to the object of the ABC class.

obj = new ABC ();

call the construction of ABC class

3 0
3 years ago
You can create a negative indent, sometimes called a(n) ________________, by dragging the indent markers on the ruler to the lef
Murljashka [212]
B is the best answer
I hope it’s work
8 0
3 years ago
What are two ways the broad-match modifier makes Jamie's work easier? (Choose two.)
Mariana [72]

Answer:

1) She doesn’t have to think of all the related saucepan keywords

2) She can easily select the colour she wants to focus on.

Explanation:

Broad match modifiers ensure  ads will only show for searches that include the words you’ve marked with a plus sign, such as +blue +suede +shoes. Broad match modifiers can help your keywords reach a greater clickthrough rate (CTR) with a more targeted customer audience, which in turn can help your site get more paying customers or other conversions

4 0
4 years ago
Other questions:
  • Your brother is starting 9th grade next year and is thinking about going to college. What step would you recommend he take?
    14·1 answer
  • Consider the following network: proxy-cache On average there are 35 objects downloaded per second, and the average object size i
    14·1 answer
  • A _______ is a piece of computer hardware used for the modulation and demodulation of data between digital and analog formats.
    10·1 answer
  • How to Ctrl + shift + F4 but in a HP laptop?​
    8·2 answers
  • Assume that given , middle and family are three variables of type string that have been assigned values . Write an expression wh
    5·1 answer
  • Adjusting the ______ adjusts the difference in appearance between light and dark areas of the photo.​
    6·1 answer
  • When computing the cost of the basket of goods and services purchased by a typical consumer, which of the following changes from
    11·1 answer
  • John is runnig his Database application on a single server with 24 Gigabytes of memory and 4 processors. The system is running s
    6·1 answer
  • A new PKI is being built at a company, but the network administrator has concerns about spikes of traffic occurring twice a day
    5·1 answer
  • Take points for free who are new and enjoye them
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!