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
siniylev [52]
3 years ago
15

Write a Java method onlyDigits that takes a string as a parameter. The method should remove from the string all characters, whic

h are not digits, and return a string that contains only digits.
Computers and Technology
1 answer:
Stels [109]3 years ago
3 0

Answer:

public static String onlyDigits(String in){

    String digitsOnly = in.replaceAll("[^0-9]", "");

    return digitsOnly;

}

A Complete program is wrtten in the explanation section

Explanation:

public class TestClass {

   public static void main(String[] args) {

     String a = "-jaskdh2367sd.27askjdfh23";

       System.out.println(onlyDigits(a));

}

public static String onlyDigits(String in){

    String digitsOnly = in.replaceAll("[^0-9]", "");

    return digitsOnly;

}

}

The output: 23672723

The main logic here is using the Java replaceAll method which returns a string after replacing all the sequence of characters that match its argument, regex with an empty string

You might be interested in
Whats the keyboard command that will allow you to copy text ?
mamaluj [8]

its ctrl c and to paste is ctrl v

8 0
3 years ago
Read 2 more answers
What is the easiest way to beat all of the fnaf games without getting killed and beating all of the nights?
MrRa [10]

Answer:

If you want the game to be "hard" be paranoid. If you are not scared, this game is simple. All you have to do is check your camera to pirate's cove to see if foxy is there. Otherwise, check the halls on your left and right. When Bonnie and/or Chica come, quickly close your doors and wait till they go away. Then, on night five, check the stage to make sure freddy has not moved. Night 5+ is the only real challenge.

Explanation:

My Strategy

Rythm is essential to surviving all the nights at Freddy Fazbears. Here is what I do.

First, check the light on the left.

If anyone is there close the door, or keep the door shut

If not, or after you have closed the door, move on to the next step.

Then, close the right door*.

Check the camera to make sure foxy has not moved.

If Foxy has moved, quickly shut the right door and check camera 2A. When your are pulled out of your camera, return to your camera and check on Foxy.

Check the right hall light.

If anyone is there close the door, or keep the door shut.

If no one is there, or you have the door shut, repeat all of these steps

5 0
3 years ago
Read 2 more answers
A label control may be added to a form by double-clicking on the Label control icon in the ________ window.
Ierofanga [76]

Answer:

ToolBox.

Explanation:

A label control may be added to a form by double-clicking on the Label control icon in the ToolBox window.

5 0
3 years ago
Which describes a design theme in PowerPoint? a set of elements that unify the slides and complement the topic a printed handout
chubhunter [2.5K]

a set of elements that unify the slides and complement the topic

5 0
4 years ago
Read 2 more answers
EdHesive 3.7 Code Practice?
devlian [24]

Answer:

if 3 + 3 == 6:

 print("Hey 3 and 3 is 6")

 if 5 + 3 == 8:

   print("You are not going to catch me")

   if 5 + 6 == 10:

     print("****nag*****")

   else:

     print("You thought like 5 + 6 = 11 ")  

     if 6 + 6 == 12:

       print("Great! This one is correct")

       if 5 + 7 == 12:

         print("Great, this is correct as well")

         if 3 + 3 == 4 and 5 + 5 == 10:

           print("Great! Congrats")

Explanation:

Please check the answer, and practice if else and various other ladders as much as you can.

8 0
4 years ago
Other questions:
  • c++ design a class named myinteger which models integers. interesting properties of the value can be determined. include these m
    14·1 answer
  • Victor has been murdered, and Art, Bob, and Carl are suspects. Art says he did not do it. He says that Bob was the victim's frie
    14·1 answer
  • When you are using inprivate browsing, the "inprivate is turned on" page displays in the browser window, the inprivate label is
    14·1 answer
  • A peer-to-peer (p2p) network is an example of ________ administration
    5·1 answer
  • Suppose that you have been running an unknown sorting algorithm. Out of curiosity, you once stopped the algorithm when it was pa
    8·1 answer
  • Describe a new career in computer science that may be created in the future. Include supporting evidence in your response that s
    13·1 answer
  • What is the FTC used car rule
    12·1 answer
  • Jacob has a text file open, and he is typing on the keyboard. What is the best description of how the
    8·1 answer
  • Which tags do you use to write the header and items of an ordered list on a web page?
    14·1 answer
  • 1. What are the main uses for Protein in the body?
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!