Question

Need some help with some Java studying. Please be as detailed as possible with the answer....

Need some help with some Java studying. Please be as detailed as possible with the answer.

- Explain the difference between a mutable and an immutable string, why it’s usually more efficient to use a mutable string, and why using an immutable string make programs safer and more robust.

- Explain how Java determines the initial capacity of a StringBuilder object and the new capacity of a StringBuilder object when its current capacity is exceeded.

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

Strings are immutable in java which means once you create the String object for that you can not change the value of that object, if you try to change the value in the object instead of chaning it will create new object with changes and returns the new object. mutable means we can change the values in the Object ex:StringBuffer and Builder

Program is efficient if we use mutable strings because if we change than it will not create new objects so it saves lot of memory

It is secure to use Strings becuase if one object is modified the content than it will get impacted to other objects as well becuase of String pool

By default StringBuilder creates with the size 16 than if capacity exceeds than it will increase like (oldSize+1) * 2

Add a comment
Know the answer?
Add Answer to:
Need some help with some Java studying. Please be as detailed as possible with the answer....
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
  • Hello, I need some help with this discussion question. It should be a detailed answer. Thank...

    Hello, I need some help with this discussion question. It should be a detailed answer. Thank you! The statement of cash flows has traditionally been thought of as the fraud-proof statement. Usually, it is the statement that is most difficult to fudge, explain why that is?  WorldCom changed everything in the early 2000s. WorldCom had reclassified $3.8 billion in expenses as capital purchases. What were they trying to accomplish on the statement of cash flows? On the income statement? What happened...

  • Hi! I really really need help with these questions, please upload as many as possible! thanks!!...

    Hi! I really really need help with these questions, please upload as many as possible! thanks!! (b) Describe the fundamental properties of a ferroelectric material. [3 MARKS] (c) Outline a procedure for the deposition of thin layers of BaTiO3. [2 MARKS] (d) Photovoltaic (PV) devices allow for the conversion of solar energy directly to electricity. The most efficient PV cells are based on silicon. (0) Explain the difference in conductivity between ultra-pure silicon, n-type silicon and p-type silicon. In your...

  • Need some help with this C++ code. Please screenshot the code if possible. Purpose: Demonstrate the...

    Need some help with this C++ code. Please screenshot the code if possible. Purpose: Demonstrate the ability to create and manipulate classes, data members, and member functions. This assignment also aims at creating a C++ project to handle multiple files (one header file and two .cpp files) at the same time. Remember to follow documentation and variable name guidelines. Create a C++ project to implement a simplified banking system. Your bank is small, so it can have a maximum of...

  • I really need some help with these questions! Thank you Please help me out with these...

    I really need some help with these questions! Thank you Please help me out with these Microeconomic questions!!! Thank you so much! I really appreciate that. 4. There exists high-ability and low-ability workers. Firms are willing to pay up to $80,000 for a high-ability worker and $20,000 for a low-ability worker. Going to college provides a signal that one is a high-ability worker at a cost of $10,000. (a) is a separating equilibrium where high-ability workers go to college and...

  • **** ITS MULTI-PART QUESTION. PLEASE MAKE SURE TO ANSWER THEM ALL. SOLVE IT BY JAVA. ****...

    **** ITS MULTI-PART QUESTION. PLEASE MAKE SURE TO ANSWER THEM ALL. SOLVE IT BY JAVA. **** *** ALSO MAKE SURE IT PASS THE TESTER FILE PLEASE*** Often when we are running a program, it will have a number of configuration options which tweak its behavior while it's running. Allow text completion? Collect anonymous usage data? These are all options our programs may use. We can store these options in an array and pass it to the program. In its simplest...

  • Hi all, I'm studying for a test for my Java class that coming up on Tuesday,...

    Hi all, I'm studying for a test for my Java class that coming up on Tuesday, and I would love it if someone could look over my answer. Can someone give me some feedback on the wrong one I get wrong? I really need to get it right for the upcoming test. Here my prep test: Which one statement is true" Question1 All objects that are eligible for garbage collection will be removed from the heap by the garbage collector....

  • JAVA: Already completed: MyList.java, MyAbstractList.java, MyArrayList.java, MyLinkedLink.java, MyStack.java, MyQueue.java. Need to complete: ReversePoem.java. This program has...

    JAVA: Already completed: MyList.java, MyAbstractList.java, MyArrayList.java, MyLinkedLink.java, MyStack.java, MyQueue.java. Need to complete: ReversePoem.java. This program has you display a pessimistic poem from a list of phrases. Next, this program has you reverse the phrases to find another more optimistic poem. Use the following algorithm. 1.   You are given a list of phrases each ending with a pound sign: ‘#’. 2.   Create a single String object from this list. 3.   Then, split the String of phrases into an array of phrases...

  • Need help in the below question. Answer in java Start with the tree.java program (Listing 8.1)...

    Need help in the below question. Answer in java Start with the tree.java program (Listing 8.1) and modify it to create a binary tree from a string of letters (like A, B, and so on) entered by the user. Each letter will be displayed in its own node. Construct the tree so that all the nodes that contain letters are leaves. Parent nodes can contain some non-letter symbol like +. Make sure that every parent node has exactly two children....

  • !!!!!!!Java!!!!! When you are confident that your methods work properly and that you can generate random...

    !!!!!!!Java!!!!! When you are confident that your methods work properly and that you can generate random text with my generateText method, you can move on to the second step. Create a third class called Generator within the cs1410 package. Make class. This class should have a main method that provides a user interface for random text generation. Your interface should work as follows: Main should bring up an input dialog with which the user can enter the desired analysis level...

  • please help me answer these questions, I provided all the information. thank you You are the...

    please help me answer these questions, I provided all the information. thank you You are the financial analyst of the Management and Budgeting Oftice (MBO) for the Procurement Agency of your Municipality The Transport system of your city needs to have an extension/renovation of the existing equipment (eg vehicles, on-board Wi-Fi network, etc.) and infrastructure (e.g. binary for bus, etc). The transport system is totally owned by the municipality, hence it is in charge of investment decision and business activity...

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
ADVERTISEMENT