Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The purpose of the discussion board is to discuss various topics related to the

ID: 3865783 • Letter: T

Question

The purpose of the discussion board is to discuss various topics related to the readings in order to enhance your understanding. Therefore, it is important that you read discussion board postings, don’t restate what someone has already said, try to further the discussion. It is okay to ask questions, pose ideas, and provide opinions.

Post 4 to 6 paragraphs on the topic to the week 9 discussion forum by Wednesday evening.

How are strings like arrays/collections? In what ways are they different (be specific)?

Be sure to cite your references.    **PLEASE CITE REFRENCES**

Explanation / Answer

I am assuming you are talking in terms of Java language, as in some languages string is a special type(Java), in some it is just an array of characters(C)

Strings are basically like arrays only.. They are internally implemented using char(primitive). A string is a collection of characters joined together, so they form a string.. Strings are similar to arrays as both have sizes, You can get the element at some particular index in both and so on...

While you can modify the value at a particular index in an array, you can not change the character at a particular index in strings.. Because strings are immutable.. means

if we create a string as "ABCD" and later we wanted the first character to be P instead of A, a new string will be created at some other memory location, and the original string ABCD will remain as it is. This is known as strings being immutable..

While in case of Arrays if a array of ints was [10, 20, 30], and we wanted to make the first entry as 40 instead of 10, we could have done it easily using a[0] = 40, and the array would have been modified in place.. That means the same copy of the array is modified and there is no need to create a new array. Hence arrays are not immutable.