One small correction in the video, when we concatenate x and y it will generate a new String in heap memory not in SCP. So in this example, "abcabc" will be stored inside the heap memory. this is the internal implementation of concat() method in java: Concat method: public String concat(String str) { int otherLen = str.length(); if (otherLen == 0) { return this; } int len = value.length; char buf[] = Arrays.copyOf(value, len + otherLen); str.getChars(buf, len); return new String(buf, true); }
Hi Naveen, Can you please tell me solutions for the question in the below. Split a String but don't split when character repeats.. input s="aHHHbYY"; Out put would be like output:[a, HHH, b, YY] Thanks in advance. Ragards, Kanvitha
Very helpful video but just one correction, at 7:51 you mentioned Strings are the most commonly used data type. But it is not data type, it is class. We can call it data storage but not data type.
String is a non primitive data type, all the classes in java comes under non primitive data types category. It is also called derived data type or reference type which refers to an object. So yes String is a data type.
Yup, SCP area is part of Heap, but is special area and JVM knows that it is not suppose to remove the constants inside it even if there is no reference to them.
@CricJammer If the SCP is not garbage collected until the JVM is shut down, is there a possibility that SCP can go out of memory? or it will start to use the native OS memory?
SCP takes advantage of special treatment from the garbage collector. The garbage collector does not visit SCP with the same frequency (cycles) as other memory zones but it does.
One small correction in the video, when we concatenate x and y it will generate a new String in heap memory not in SCP. So in this example, "abcabc" will be stored inside the heap memory.
this is the internal implementation of concat() method in java:
Concat method:
public String concat(String str)
{
int otherLen = str.length();
if (otherLen == 0) {
return this;
}
int len = value.length;
char buf[] = Arrays.copyOf(value, len + otherLen);
str.getChars(buf, len);
return new String(buf, true);
}
Great... Create series like this which covers small nd important topic... Waiting for next one...👍
thank you Naveen :)
Simply amazing
First comment sir...youre superb sir
Hi Naveen,
Can you please tell me solutions for the question in the below.
Split a String but don't split when character repeats.. input s="aHHHbYY";
Out put would be like output:[a, HHH, b, YY]
Thanks in advance.
Ragards,
Kanvitha
Amazing explanation......
Hi Naveen, could you please tell some tips to clear client round. It would be helpful
The value of x is abc Naveen in this question
Very helpful video but just one correction, at 7:51 you mentioned Strings are the most commonly used data type. But it is not data type, it is class. We can call it data storage but not data type.
String is a non primitive data type, all the classes in java comes under non primitive data types category. It is also called derived data type or reference type which refers to an object.
So yes String is a data type.
Good video make a series'
Since abcabc is not refered by anyone , will it be removed by GC ?
No, GC can not access the SCP area. It is wiped off when JVM is shutdown. Because of SCP, it is faster to use String.
@@Iam_namangupta But from Java 7 SCP is the part of heap memory only
Yup, SCP area is part of Heap, but is special area and JVM knows that it is not suppose to remove the constants inside it even if there is no reference to them.
@CricJammer If the SCP is not garbage collected until the JVM is shut down, is there a possibility that SCP can go out of memory? or it will start to use the native OS memory?
SCP takes advantage of special treatment from the garbage collector. The garbage collector does not visit SCP with the same frequency (cycles) as other memory zones but it does.
abc
x