How a string is immutable
Bcoz we can still modify a string e.g."pine"+"apple"=pineapple Here the string pine is modified.... So plz explain
the string is not modified but rather a new stri g is made and is referenced 1) x="hello" 2) y="world" 3) x=x+" "+y what happens above is that on line 3 we assign a new concatanated string to x, destroying what was there before. so we are not actually adding, but assigning something new constructed from the old
A String is an object of the string class. your addition operator is only an abstraction to indicate the creation of a new String object that will hod the data resulting from the concatenation of two other objects.
Here pineapple is a new string. eg. 2+3=5 here 2 is not modified into 5.
How do I generate a list with <N> unique elements randomly selected from another (already existing) list?
Given three integer matrices A(m*n),B(m*n) and C(m*n) . Print the one with more zero elements. beside code
I'm coding this for hours & can't make the value of the 5 random numbers round off to 2 decimal places like in the examples
Overloading + operator