Question

1. What is the difference between 'String' objects and 'StringBuilder' objects? 2, List and define three...

1. What is the difference between 'String' objects and 'StringBuilder' objects?

2, List and define three methods contained in class 'Matcher'

0 0
Add a comment Improve this question Transcribed image text
Answer #1

1 Ans) The main difference between 'String' objects and 'StringBuilder' objects is that 'String' objects are immutable whereas 'StringBuilder' objects are mutable. By immutable it means that the value of a String object cannot be changed. So, whenever we perform some operations on String object which changes the value of String internally a new String object will be created. But 'StringBuilder' objects are mutable means that their value can be changed and no new StringBuilder objects will be created when we change the value.

2 Ans) The 'Matcher' class is used to search a string for multiple occurrences of a regular expression.

Below are the examples of three methods contained in 'Matcher' class

1)public boolean matches()

The matches() method returns true if regular expression is matched against the whole string passed to the Pattern.matcher() method when the Matcher was created , otherwise returns false

2)public boolean lookingAt()

The lookingAt() method returns true if regular expression is matched against the starting of the string passed to the Pattern.matcher() method when the Matcher was created , otherwise returns false

3)public boolean find()

The find() method searches for occurrences of the regular expressions in the text passed to the Pattern.matcher(text) method, when the Matcher was created. If multiple matches are found in the text, the find() method will find the first, and then for each subsequent call to find() it will move to the next match.

Add a comment
Know the answer?
Add Answer to:
1. What is the difference between 'String' objects and 'StringBuilder' objects? 2, List and define three...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • What is the difference between the String class and the StringBuilder class in the API? Group...

    What is the difference between the String class and the StringBuilder class in the API? Group of answer choices they are in different packages a String can only contain letters while a StringBuilder can contain any character a String is immutable and a StringBuilder is mutable there is no difference A class can directly extend many classes. Group of answer choices True False With this declaration: Student s1; What possible values can s1 hold? Group of answer choices с a...

  • 1. Define the difference between sterilization and disinfection. 2. Define the difference between a disinfectant and...

    1. Define the difference between sterilization and disinfection. 2. Define the difference between a disinfectant and an antiseptic. 3. List one chemical and one physical method of disinfection. 4. List two areas or items that would need to be sterilized. 5. Gram negative and gram positive organisms have different sensitivities to disinfectants and antiseptics. Explain why.

  • 1. Define customer service and list its goals and challenges. 2. What is the difference between...

    1. Define customer service and list its goals and challenges. 2. What is the difference between internal and external customers? What are the benefits of serving both internal and external customers? 3. List the needs of customers. 4. What are the characteristics of a social customer? Why are “listening tools” important for providing excellent customer service? 5. What is a contact point? 6 - 7. Type the 2 customer service tips in chapter 1 word-for word.

  • Suppose we define a class called "Something" that maintains a list of objects of some type....

    Suppose we define a class called "Something" that maintains a list of objects of some type. Suppose further that we declare methods "doA" and "doB" in the class. Method "doA" has a void return type and takes an object received as an input argument and adds it to the end of the list. Method "doB" removes the object that is in the first position in the list and returns it. What type of abstract data structure does the class represent?

  • hello there, still confused. What is the difference between a c-string and a string class object?...

    hello there, still confused. What is the difference between a c-string and a string class object? In a short paragraph describe three differences.

  • You will write three static methods to manipulate an input String in different ways using various...

    You will write three static methods to manipulate an input String in different ways using various String methods. You need to provide the code for each of the three static methods in class StringPlay (requirements for each listed below). You will also change the control statement in the test harness to allow for variations in the sentinel value. You need to modify the loop control condition in Lab09.java so that user inputs of ‘finish’, “FINISH”, “FiniSH”, “fINISH”, etc. will end...

  • 1. What is the difference between mortar and cement? 2. Define the curing process. 3. Define...

    1. What is the difference between mortar and cement? 2. Define the curing process. 3. Define the hydration process. 4. What is the rule of aggregates?

  • Define a C++ class managing objects using a Linked List. (10 points) Define a C++ class...

    Define a C++ class managing objects using a Linked List. (10 points) Define a C++ class named "BirthdayList" that manages a list of Birthday objects as a linked list maintaining the order of entry (first birthday should be displayed first). Write a main function to show that you can add a list of birthdays and print out that list in the order that you have entered. (5 points) Add a "search" method into the "BirthdayList" class that accepts a Birthday...

  • Using loops with the String and Character classes. You can also use the StringBuilder class to...

    Using loops with the String and Character classes. You can also use the StringBuilder class to concatenate all the error messages. Floating point literals can be expressed as digits with one decimal point or using scientific notation. 1 The only valid characters are digits (0 through 9) At most one decimal point. At most one occurrence of the letter 'E' At most two positive or negative signs. examples of valid expressions: 3.14159 -2.54 2.453E3 I 66.3E-5 Write a class definition...

  • Define an interface FarmAnimal that contains two methods: getName() and talk(), each returns a string. Declare...

    Define an interface FarmAnimal that contains two methods: getName() and talk(), each returns a string. Declare an abstract class FarmAnimalBase that implements the interface FarmAnimal. In the class FarmAnimalBase, define a private final instance variable name (type: String), a public constructor that initializes the value of the instance variable name, and a public method getName() that returns the value of the instance variable name. Note that we do not implement the method talk() declared in the interface FarmAnimal, that’s the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT