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
jekas [21]
3 years ago
13

How do I find a space in my String and replace it? JAVA

Computers and Technology
1 answer:
Fantom [35]3 years ago
8 0

Answer:

This article shows how to use regex to remove spaces in between a String.

A string with spaces in between.

String text = "Hello World Java.";

We want to remove the spaces and display it as below:

Hello World Java.

1. Java regex remove spaces

In Java, we can use regex \\s+ to match whitespace characters, and replaceAll("\\s+", " ") to replace them with a single space.

Regex explanation.

`\\s` # Matches whitespace characters.

+ # One or more

StringRemoveSpaces.java

package com.mkyong.regex.string;

public class StringRemoveSpaces {

public static void main(String[] args) {

String text = "Hello World Java.";

String result = text.replaceAll("\\s+", " ");

System.out.println(result);

}

}

Output

Terminal

Hello World Java.

You might be interested in
The most popular transmission media option for wired home ethernet networks is ________ cable. fiber-optic power-line unshielded
tino4ka555 [31]
<span>This is called an unshielded twisted pair cable, which is also known as a UTP cable. This type of cable has four pairs of wires that are twisted around each other. Because the wires are like this, the electrical interference is reduced.</span>
3 0
4 years ago
The retention of encoded information over time refers to
Crank

It refers to Storage

7 0
2 years ago
Complete the sentences about interactive media.
maksim [4K]

Answer:

teletext

dynamic media

Explanation:

5 0
3 years ago
What do both wireless lans (wlans) and wireless wans (wwans) rely on as the communication medium?
AnnyKZ [126]

Wireless lans (WLANS) and wireless wans (wwans) rely on as the radio frequency spectrum communication medium.

<h3>What is Radio spectrum?</h3>

The radio spectrum is known to be an aspect of the electromagnetic spectrum that is said to have frequencies from 0 Hz to 3,000 GHz.

Note that Wireless lans (WLANS) and wireless wans (wwans) rely on as the radio frequency spectrum communication medium for their functions.

Learn more about WLANS from

brainly.com/question/26956118

#SPJ12

4 0
2 years ago
Suppose there are 2 routers in sequence between Host A and Host B, all of which use store-and-forward routing. What is the total
lora16 [44]

Answer:

Check the explanation

Explanation:

Going by the question above,there are 2 routers in a sequence amid Host A and Host B and using store-and-forward routing.

So that time would conprise of both propagation delay and transmission time

Propagation delay is nothing but the time taken for traveling.

Transmission delay is the amount of delay time from the beginning to end of transmission)

Now,

Propagation delay = distance traveled / speed of propagation

= 161200 / 2.7 *108 = 59703703.70 * 10-8 mili sec

Transmission delay:

= packet size / bandwidth

= 4 / (9.1 * 1024) = 4.2925 * 10-1 mili sec

Let us assume routers have zero (0) processing time

total time = Transmission delay by host A + Transmssion delay by router1 + Transmssion delay by router2 + propagation time

= 3 * ( 4.2925 * 10-1 ) + (59703703.70 * 10-8)

= 1.28775 + 0.5970370370 ms

= 1.884787 ms

6 0
3 years ago
Other questions:
  • PLEASE HELP ITS EASY I JUST BIG STOOPYHEAD!!!!
    5·2 answers
  • When using Microsoft word, what would happen to the text of a paragraph if the "Justify" option is used?
    9·1 answer
  • The material placed around the ignition device to feed the flame in arson is referred to as
    8·1 answer
  • True or False. A list can have only the same data type values.
    13·1 answer
  • If a user wants to add an expansion card to increase the memory of a computer, where should the user insert the card?
    12·2 answers
  • Select the correct answer.
    7·1 answer
  • Rewrite the following program segment using a while loop instead of a for loop.
    11·1 answer
  • Write a python program to print numbers from 100 to 50 using for loop.<br> I NEED THIS URGENT PLEASE
    9·1 answer
  • Where can i check on an acer chromebook to see what version of java is installed.
    13·1 answer
  • A technician is testing a connector in a circuit with a voltmeter. With the power on in the circuit, the meter reads 12 volts wh
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!