Why string is immutable in java || The 4 reasons you must know || part 1

Поделиться
HTML-код
  • Опубликовано: 18 ноя 2024

Комментарии • 190

  • @souravsarkar1615
    @souravsarkar1615 6 лет назад +10

    String s = ""ABC" vs String s = new String("ABC"); Can u explain this?

    • @SeleniumExpress
      @SeleniumExpress  6 лет назад +81

      Sourav,
      Just think about a normal Object creation.
      class Sourav
      {
      }
      Sourav sourav = new Sourav();
      here the object “sourav” is going to be stored in heap memory.why?
      because the object creation is a runtime operation and all the runtime stuff gets stored in the heap memory. just think like if you are using the keyword “new”, then that's a run time operation.
      case 2:
      in the above case, Sourav is a normal class. But what about if I create an object for the String class.
      String sourav = new String(“Sourav Sarkar”);
      here the above object “sourav”is a little special. Why ? because it’s a String class object and you might have already figured it out that something tricky is going on here.right?
      but it’s very simple.
      so first let’s apply our logic.sourav is a what? it’s an object. if it’s an object where it is going to be stored? of course, the answer is, in the heap memory. right?. So as of now, one object is already created inside the heap.
      now the next thing, I told you the string class is a little special. and the object “sourav” is a String class object.
      So to store the string objects, we also have something called, String constant pool(SCP) which exits inside the Heap memory only. Imagine like, you have a box(heap) and inside that box, you have another small box(SCP) which will store all the constants. In the above case, first the object got created in heap because crating object is a runtime operation, and then “Sourav Sarkar
      " is a constant too, so another object got created inside the SCP(the job of scp is to store constants). So whenever we use the new keyword to create a string object, two objects get created, one in the heap and one in the scp.
      But what about
      String sourav = “Sourav Sarkar”; //it’s an another way to create a String object
      here tell me, are we using the new keyword? nope, right? so if we are not using any new keyword it’s not a runtime operation, so no chances of object creation in the heap. but wait, “Sourav Sarkar
      “ is a constant here and where we store the String constants ? in the String constant pool(SCP) right? so an object will be created inside the SCP.
      So, in this case, only one object will be created and that will be inside the SCP.
      now here is a task for you.
      String str = new String(“abhilash”);
      str.concate(“Panigrahi”);
      let me know how many objects will be created in the memory? A clue for you is concate(“panigrahi”) is a runtime operation.it’s tricky but just apply the logic.you can surely do it.

    • @souravsarkar1615
      @souravsarkar1615 6 лет назад +22

      @@SeleniumExpress
      Case 1 : String str = new String(“abhilash”); here this is a run-time opertion because we are creating String object using new keyword. So one object will be created in the heap.
      But here "abhilash" is a constant, so another object will be created in string constant pool.
      So, here two objects will be created for case 1.
      Case 2 : str.concate(“Panigrahi”);
      here concate is runtime operation so one object will be created in heap.
      but "Panigrahi" is a constant too, so another object will be created in the string constant pool.
      So, here two objects will be created.
      So the conclusion is that, total four objects will be created.

    • @SeleniumExpress
      @SeleniumExpress  6 лет назад +13

      Spot on !! You are awesome!! 👍

    • @shabanakareem
      @shabanakareem 5 лет назад +7

      @@SeleniumExpress sir gr8...the way u explain jst awsome...

    • @pradeepmedikonda7282
      @pradeepmedikonda7282 5 лет назад +8

      @@souravsarkar1615 not four objects it is only three ibjects because already heap had the earlier one oject so it is just point to another object it will not create another object of new keyword

  • @Kumarkumar-gf3kk
    @Kumarkumar-gf3kk 4 года назад

    I Leared today on .Intern(), By applying String. intern() on a couple of strings will ensure that all strings having the same contents share the same memory.
    clear cut explanation! Highly appreciated!

  • @albeliever
    @albeliever 5 лет назад +2

    By new keyword : Java String is created by using a keyword “new”. For example: String s=new String(“Welcome”); It creates two objects (in String pool and in heap) and one reference variable where the variable 's' will refer to the object in the heap.

  • @pogo874u
    @pogo874u 6 лет назад +1

    All your contents are really good with explanation on how things internally work and that's what makes it a class apart. I see few people's comment to correct your accent , but trust me you don't have to if you want followers from other country.
    I'm working in an investment banking company and i see lot of Indians who are settled in US speak the same way so that others get their accent as they (Americans or people from Europe) don't get our accent that easily.

  • @akulasarika7078
    @akulasarika7078 6 лет назад +1

    After this vedio i got to know clearly what is mutable and also about heap and constant pool.. Thank you so much avilash 😊

  • @PankajKumar-qk8oh
    @PankajKumar-qk8oh 6 лет назад +7

    kindly upload videos for project of real time like Banking Application and finance domain with spring ,hibernate and restwebservices.

  • @athirashree6820
    @athirashree6820 4 года назад

    Very useful sir..ThankYou

  • @shauvikpujari9522
    @shauvikpujari9522 4 года назад

    Explanation was awesome sir👍👌

  • @rawatpraveen1000
    @rawatpraveen1000 3 года назад

    I recently started watching your videos! You are doing an awesome job! thanks

  • @shashankmm5908
    @shashankmm5908 3 года назад +1

    Hmm... I have a different thought on this. This video explains that strings are immutable because of the string pool. However, I'm going to say that it's the opposite - String pool essentially works due to the immutable nature of strings.
    So, what's the actual reason for the immutable nature of strings? Here's a theory - A string is stored internally as an array of bytes.
    1. What happens when a string is modified?
    The byte array will most likely need to be resized.
    2. What if the array cannot be resized because the subsequent blocks of memory are already occupied?
    A new byte array needs to be created with a sufficient size, all bytes from the current string copied over to the new array, free up the old array eventually (GC).
    Now, #2 is going to happen in almost every scenario. So, that's immutability occurring automatically by itself. Since that already happens, it probably makes sense to make it behave immutably for every string because it's probably more efficient that way, rather than handling every specific case.
    Now because strings can behave as immutables almost automatically, a string pool helps in keeping a check on memory to a certain degree. Even the concept of using strings as hashes is due the same reason.
    So, string pool and string hashes are a result of the immutable nature of strings and NOT the other way round.

  • @hardikjain9971
    @hardikjain9971 3 года назад

    Awesome Explanation bro!!

  • @Srini8174
    @Srini8174 3 года назад

    Thank you for clear explanation

  • @anjurawatkathait1400
    @anjurawatkathait1400 4 года назад

    Very Impressive, I dint know the main purpose of intern(). Concepts are very much clear to me . Thanks

  • @pradipbehera6542
    @pradipbehera6542 3 года назад

    Very nice explanation

  • @rameshbabu5754
    @rameshbabu5754 5 лет назад +1

    I am following your all videos relay its good conception and explanation also that is the reason I am asking to you

  • @ShwetaHosur
    @ShwetaHosur 4 года назад

    Very Helpful video

  • @rameshbabu5754
    @rameshbabu5754 5 лет назад +1

    because your explanation is very very good sir please can you do oops concept videos

  • @arjuarju456
    @arjuarju456 2 года назад

    explaining on board is more better than computer so try to make more videos by explaining on board only bro.. masth explaination by the way

  • @shekark1223
    @shekark1223 6 лет назад +2

    superb bro, all I knew earlier except that intern() method part. Thanks for letting me know a new thing

    • @SeleniumExpress
      @SeleniumExpress  6 лет назад +1

      Happy to know that, Shekar.
      Watching a video for 20 minutes, where you already know the content is appreciable. You are an awesome learner.

  • @RajatAsthana24
    @RajatAsthana24 4 года назад

    Please make a tutorial series on multithreading or suggest a good source to learn the same

  • @ajaywadhwa3398
    @ajaywadhwa3398 3 года назад

    Your video just blow my mind.

  • @alvaroisea2259
    @alvaroisea2259 3 года назад

    Thanks, valuable info here!!!

  • @himachilukuru6337
    @himachilukuru6337 5 лет назад

    Your video are seriously goo...but some videos lack clarity of voice, pls do look at it. Thanks again for wonderful explaination

  • @saimanasa8904
    @saimanasa8904 4 года назад

    Sir please create a video on stringbuffer and stringbuilder

  • @ashakankanampati1159
    @ashakankanampati1159 3 года назад +1

    Bro can you please upload the core java playlist also

  • @Srini8174
    @Srini8174 3 года назад

    Clear explanation

  • @viveksharma878
    @viveksharma878 6 лет назад

    Very Use full tutorial thanks for making this

  • @Kumarkumar-gf3kk
    @Kumarkumar-gf3kk 4 года назад

    Excellent explanation on .intern()

  • @rameshbabu5754
    @rameshbabu5754 5 лет назад +1

    please can you explain oops concepts videos with real time explanation and examples with clear concepts

  • @ravindravs9821
    @ravindravs9821 4 года назад

    Can you please explain on Completionstage and completablefuture topics

  • @vv7584
    @vv7584 3 года назад

    Dear instructor,
    I have two questions,
    1. What is String pull in general? is it an object in heap memory yes?
    2. Nevertheless the comparison of String s = ""ABC" vs String s = new String("ABC") is already discussed, but in one tutorial instructor mentions that even when we create String in String s = new String("ABC") way the object is created in heap but that object points to the "ABC" value in string pool, is this what happens behind the scenes? Or when we do new then a String object is created only in heap which holds ABC value? So if string pull is empty and we create new String("ABC") object then it will be created in the heap and string poll will still stay empty?
    Thanks

  • @Rajnish089
    @Rajnish089 6 лет назад +1

    Avi you are doing a great job. You are very clear with the point that you explain. Just one suggestion if you can consolidate all the things together in one real time project. Very few person come with such an clear explanation.

    • @SeleniumExpress
      @SeleniumExpress  6 лет назад

      Hi Rajnish,
      Thanks for the suggestion. I will be having an another video on my channel where I will cover how immutability of string help us in a multi threading environment and in web world. I will try to come up with some real-time stuff.

    • @Rajnish089
      @Rajnish089 6 лет назад

      Will be waiting eagerly for the stuff.

  • @amolnawale2177
    @amolnawale2177 5 лет назад +2

    Hey Thanks a lot Avi. Your style of explaining the concepts is really very good. You go in depth to explain the concept. Really appreciate your efforts. Request you to start a series on Collection Framework and also on Java 8.

  • @sadashivudubalabhadra4186
    @sadashivudubalabhadra4186 4 года назад

    Plz create videos on LinkedList, LinkedHashMap, HashSet..

  • @balanssocial1880
    @balanssocial1880 6 лет назад

    Hi Avi You have clearly explained the concept. great job. I 'have also gone through all the comments below.. You explained all the queries with care. Nice will surely browse through your videos.

    • @SeleniumExpress
      @SeleniumExpress  6 лет назад

      Thank's for the kind words and I am glad that you found it clear.
      Happy learning!!

    • @balanssocial1880
      @balanssocial1880 6 лет назад

      As You've said I absolutely cleared on immutability of String and thanks for ur reply

  • @yoshitamahajan353
    @yoshitamahajan353 4 года назад

    Please make video on why java is pass by value and not pass by reference ..

    • @SeleniumExpress
      @SeleniumExpress  4 года назад

      I will do, Yoshita !! Thank you for Suggesting.

  • @gauravshirskar5633
    @gauravshirskar5633 3 года назад

    Great explanation 👍 I have one question .. what happen with heap memory objects when are you using intern method is it for garbage or else?

  • @sadashivudubalabhadra4186
    @sadashivudubalabhadra4186 4 года назад

    Plz do video on java threads

  • @vandana2604
    @vandana2604 6 лет назад +4

    have you covered OOPs(abstraction/Inheritance/Polymorphism/Encapsulation) concept in one video kindly give me the link..

  • @rameshbabu5754
    @rameshbabu5754 5 лет назад +1

    please can you do the Multi-Threding videos in Java. I am facing this issue so many times in Interview
    But I couldn't clear this type of quation in Interview

  • @umeshjoshi8047
    @umeshjoshi8047 2 года назад

    @Selenium Express have some query related to String immutable
    public class Main
    {
    public static void main(String[] args) {
    String s="Selenium Express";
    String s1="Selenium Express";
    s=s.concat("RUclips");
    }
    }
    in this case after i concat "RUclips" to s and assign it to reference s new object will be created in Heap and also in String Constant Pool ,will s ="Selenium Express" is still present in SCP or s reference will be removed ? .
    Isn't we are modify same string s
    Thanks

  • @pavithram4876
    @pavithram4876 4 года назад +1

    In the following example I am getting the output as "References are unequal' but i am expecting the output as "References are equal" since S3 and S4 are created using string class. Can you explain me this
    String S1="Mary";
    String S2="John";
    String S3=S1+S2;
    String S4=S1+S2;
    if (S3==S4)
    SOP("References are equal");
    else
    SOP("References are unequal");

  • @jatinsharma1915
    @jatinsharma1915 4 года назад

    Sir, how does garbage collector works in string constant pool?
    Since you said that string objects are cached in SCP, there should be some provisions to delete the objects present in SCP which are no longer in use or else we will eventually run out of memory.

  • @Kumarkumar-gf3kk
    @Kumarkumar-gf3kk 4 года назад

    very nice, well explained appreciate!

  • @rameshbabu5754
    @rameshbabu5754 5 лет назад +2

    number of time I got oops concept question but I am not clear on that sir. please can you do that videos sir

  • @santoshkumarsahoo1103
    @santoshkumarsahoo1103 5 лет назад

    Abhilash Bhai, please make a video on spring jdbc with depth and internals with suitable examples....

    • @SeleniumExpress
      @SeleniumExpress  5 лет назад

      Sure, Santosh.. Will do.. Now a little busy with the upcoming core videos. Once done, will definitely make a series on jdbc.😊

  • @prasantaroutray1981
    @prasantaroutray1981 6 лет назад +1

    super explanation panigrahi..keep it up with u..and u r from odisha i guess.so proud to be odiya.

    • @SeleniumExpress
      @SeleniumExpress  6 лет назад +1

      Thank you for appreciating, Prasanta.Glad, you found it helpful.
      And yes, you guessed it right.I am from Odisha.

  • @rameshbabu5754
    @rameshbabu5754 5 лет назад

    Please can you do this video
    How to remove the duplicate values in A string or Integer without using any default methods?

  • @jagannathrao1715
    @jagannathrao1715 4 года назад

    Can you please explain about String s="raja" and the same variable we are taking s="rao"; and we print sop(s); then why the content is changing.

  • @chaitanyapatil3279
    @chaitanyapatil3279 5 лет назад

    Can you please explain how the memory is decided or checked inside SCP or heap weather the object is present or not?
    Eg String str=new String("avi"); it will create object in both heap and SCP?
    and String s1= "avi"; will point to same only?

  • @musicvibes360
    @musicvibes360 2 года назад

    i have question for is java is call by value or call by reference?

  • @pradeepmedikonda7282
    @pradeepmedikonda7282 5 лет назад

    Not only for memory constraints and further more like sharing properties for the different objects

  • @sureshm2047
    @sureshm2047 6 лет назад +3

    Hi could you please prepare one video about comparable and comparator please

  • @ajaykumarracharla4432
    @ajaykumarracharla4432 4 года назад

    String s = new String ("abc");
    s.concate("xyz");
    It's create new obj or ?

  • @sahilrealme7512
    @sahilrealme7512 5 лет назад

    Excellent!

  • @vinayrai3641
    @vinayrai3641 6 лет назад

    Hi Avi, What is the use of creating new String() in the heap area if we have already string literal in the SCP. Can you please explore over this.

    • @SeleniumExpress
      @SeleniumExpress  6 лет назад

      Hi Vinay,
      You right on your point. Using " " you can create a string on the pool directly which is memory efficient. But using new keyword or by using constructor you too have an option to create an string object.
      The time you are going to need it, think about an situation when you need to convert an Char array to a string, you might need an constructor of string class which accept a char array, to convert that array to string.
      Eg
      char charArray[] = {'a','b','h','i'}; String convertingCharArray= new String(charArray) System.out.println(convertingCharArray); //abhi
      Like that , we can get few different constructor of String class which is used to construct a string by passing different argument.
      Please refer the below url which will redirect you to the string api and find the constructor section .
      docs.oracle.com/javase/7/docs/api/

  • @saurabhkaranjkar8131
    @saurabhkaranjkar8131 6 лет назад +1

    Hey Avi i have one question.
    Why our java file name must be the same as public class name ?
    We can take any number of classes in a java file why only one public class is allowed and whose name should be class name ?
    i hope u will answer my question, coz i have been asked this question in many interviews but im not getting clarification any where else.

  • @jaydipmakwana9390
    @jaydipmakwana9390 3 года назад

    String s1 = new String("AB");
    String s2 = "AB"
    Total 3 object would be created ?

    • @kuntasunny8688
      @kuntasunny8688 2 года назад

      as per my understanding only 2 because first line creates AB in heap as well as scp, second line will not create AB in scp because AB is already there in scp so s2 will just point to already existing AB . simple

  • @AlokKumar-ib2xl
    @AlokKumar-ib2xl 6 лет назад

    Badhiya kahucha bro...carry on..feel proud on you

  • @dharmala80
    @dharmala80 6 лет назад +1

    nice explanation. can you also do videos on selenium interview questions please

  • @mohammedabahussain4562
    @mohammedabahussain4562 4 года назад

    public class Main {
    public static void main(String[] args) {
    System.out.println("Thanks Selenium for the tut.");
    String first="Testing SCP",
    second= new String("Testing SCP"),
    third= new String("Testing SCP").intern(),
    fourth= "Testing SCP";
    System.out.println(fourth==first); //true
    System.out.println(fourth==second); //false
    System.out.println(fourth==third); //true
    }
    }

  • @bijaykishorepatra8113
    @bijaykishorepatra8113 5 лет назад +1

    Bhai Hibernate bootstraping 3.x,4.x 5.x upare gote bhala video baneiki upload kara....

  • @thodi_thand_paa
    @thodi_thand_paa 6 лет назад +2

    Hey Avi. Good description of the concepts. I wanted to know the use of intern method. What;s the use of creating an instance with new keyword if we pointed it to scp using intern. We could have directly created the string using literals right?

    • @SeleniumExpress
      @SeleniumExpress  6 лет назад +5

      Hi Manmeet,
      You right on your point. Using " " you can create a string on the pool directly which is memory efficient. But using new keyword or by using constructor you too have an option to create an string object.
      The time you are going to need it, think about an situation when you need to convert an Char array to a string, you might need an constructor of string class which accept a char array, to convert that array to string.
      Eg
      char charArray[] = {'a','b','h','i'}; String convertingCharArray= new String(charArray) System.out.println(convertingCharArray); //abhi
      Like that , we can get few different constructor of String class which is used to construct a string by passing different argument.
      Please refer the below url which will redirect you to the string api and find the constructor section .
      docs.oracle.com/javase/7/docs/api/
      Feel free to post an another question if you have one.

  • @emmaaloysius4241
    @emmaaloysius4241 5 лет назад

    Could you please recommend books for comprehending these concepts

  • @manjushanmugam4967
    @manjushanmugam4967 5 лет назад

    Hi bro, is that only string data type uses string constant pool.. what about other data type..

  • @yogeshwarang5112
    @yogeshwarang5112 3 года назад

    Hi.. please explain.. below mentioned code.. I have little confusion.. String a="hi"; a="hello";
    In this situation string a value to be changed.. so how is it possible? Please solve this asap.. thank you

  • @rjeevan8760
    @rjeevan8760 5 лет назад

    Hi Avilash !
    According to this video. I like this explanation, but I have small doubt please do clarify.
    As we can see that you saying because of "String Constant Pool" the "String is Immutable". Is this correct because I heard that "String Constant Pool" is introduced after "String Immutable" introduction. So how can you tell that because "String Constant Pool" so on so process "String is Immutable". Please do clarify on this point.
    And I assume that String is Immutable because we use the String value as an key in hashmap which is popular !!!

    • @SeleniumExpress
      @SeleniumExpress  5 лет назад

      You are correct, string is immutable for many reasons.
      As you said its used as a key in hashmap.
      It's too, popular for hashcode caching as well.
      String immutable nature also helps us to use it for security purpose. For an example, think that we are using it as parameters in DriverManager.getConnection().all parameters inside that methods like url, username, password are Strings.
      Even if a hacker wants to change it ,he will end up creating a new object as string is immutable.
      String is immutable, so by default it's thread safe.
      it has many reasons like this.you can verify it in Java docs.

  • @Dyslexic_Neuron
    @Dyslexic_Neuron 5 лет назад

    How is the equality and hashcode methods overridden in strings to differentiate between strings created as literals and those created using new keyword ?

  • @cvarun9221
    @cvarun9221 4 года назад

    TBh I just found 1 reason why strings are immutable. And that's because of the pooling functionality. What are the rest ?

  • @maan9011
    @maan9011 3 года назад

    V nice no suggestion but why channel name is selenium I avoid ur channel I thought it's related to testing

  • @rahulrao_gonda
    @rahulrao_gonda 5 лет назад +4

    Sir Please do a video on RESTFUL webservices .. Thanks in advance :)

  • @mohanas6697
    @mohanas6697 6 лет назад +3

    Hi Avi, regarding intern() method, if s1 points to the reference in SCP, then a new object will still be created in Heap and allocates a memory for it with the same content ?

    • @SeleniumExpress
      @SeleniumExpress  6 лет назад +4

      Hi Mohan.
      Yes, If we will create another string object with the same content again(using the new keyword), then it is going to create a different object in the heap. To point that object to SCP, again we need to use intern method.
      Please refer the below code.
      String str = "Avi";
      String str1 = new String("Avi").intern();
      System.out.println(str == str1);//true
      String str2 = new String("Avi");
      System.out.println(str==str2);// false
      Please Keep me posted, If this answer doesn't help.

    • @mohanas6697
      @mohanas6697 6 лет назад

      Great. I got it..,thanks for your reply :-)

    • @mallis003
      @mallis003 6 лет назад

      @@SeleniumExpress Hi Avilash, thanks for above code, it also help me to understand how "==" and ".equals" are works

    • @manasranjan5232
      @manasranjan5232 6 лет назад

      Bhai tame kn odisha ru?

    • @amnahmahmood4067
      @amnahmahmood4067 4 года назад

      @@SeleniumExpress Hi Avilash, quick question, so why would we want to do String str1 = new String("Avi").intern() when the reference is going to be pointing to the string literal in SCP and not the object created in heap? Wouldn't this object get garbage collected since there is nothing pointing to it. P.s. Thank you for your videos, you are so amazing!

  • @thannasip8001
    @thannasip8001 5 лет назад

    so can i modify objects which is in heap?

  • @jonwinder1861
    @jonwinder1861 4 года назад

    What if i had String str = "Jon" and String str1 = "jon" i take that they will be two difference ref variables?

  • @aniketjain3875
    @aniketjain3875 6 лет назад +1

    Dear I have question
    1.
    String s = 'avi';
    String s1=new ('avi');
    sys(s.hashcode());
    Sys(s1.hashcode());
    Output -> -1200,1200
    You say s1 is created in heap memory and s is created in SCP then how we get false if both are pointing to same memory location
    2. If I use intern() then I get true I am not understanding this scenario ..plz respond me

    • @SeleniumExpress
      @SeleniumExpress  6 лет назад +6

      Hi Aniket,
      Thank you for posting a comment.
      So when you create 's1' object, you used the new keyword.As object creation is done at runtime, the s1 object goes to heap area. and 's1' is pointing to the object which is there in heap area.
      when you create 's' object, you have use double quote or " " to create the object.When you create an object like this(using " "), it's called a constant, so it goes to SCP.
      so in this case, an object will create in SCP and 's' is pointing to that object.
      So in the above scenario, two different objects got created one in heap and one in SCP respectively. so these are the different object. 's1' and 's' are not pointing to the same object.That's why you got false if you compare them (s1==s2) .(double equals (==) checks reference)
      Don't be confused with the hashcode.hashcode is coming same because both the content is same.but what matters is how you are creating the object.Is it by using new keyword or by using " " .
      Question 2 :
      when you interning an object by using the intern method the reference is moving to SCP.
      for an example
      if you create an object like below
      String s = "aniket";
      then an Object will be created in SCP (as you have used "" to create the object) and s will be pointing to the object in SCP.
      And again when you are trying to create an object by using a new keyword like below :
      String s1 = new String("aniket");
      an object is getting created in the heap as you are using new keyword and no other object is going to be created in SCP as 'aniket' is already present there.
      and as I described you already, if you are using new keyword the reference is going to point to heap.
      but if you want to move the reference to SCP or if you want to use the object 'aniket', which is there in SCP then you have to use intern().
      for an example :
      String s1 = new String("aniket").intern();
      now the reference will move to SCP .
      so both 's' and 's1' object pointing to the same object in the SCP and you get 'true' as a result if you compare them (s==s1")
      let me know if you don't get me.you can refer the below video for string object creation.
      ruclips.net/video/xldyBBdpknM/видео.html
      keep me posted if you have any further queries.
      Have a nice time Aniket!!

    • @zippy.gaurav
      @zippy.gaurav 6 лет назад

      @@SeleniumExpress Really nice explanation. Thanks! :)

  • @saisriamara1751
    @saisriamara1751 5 лет назад

    Hi, can you suggest what will happen with below code?
    String str="avi";
    str = str.concat("lash");
    In this string allowing me to mute the object, may i know the reason?

    • @SuperAamir9
      @SuperAamir9 5 лет назад

      Its because ur using the same refernece str while concating it.

  • @ishaaggarwal5467
    @ishaaggarwal5467 5 лет назад

    While using. concat() method, new object is created in heap memory and not in String Pool Constant area. Why?

  • @pavanvyas2879
    @pavanvyas2879 6 лет назад

    this is what the power of hyderabad.. i like it

  • @DilipKumar_1309
    @DilipKumar_1309 4 года назад

    What will happen if I use intern() and the string will not in string constant pool?

  • @achintyasett9621
    @achintyasett9621 4 года назад

    @seleniumexpress Are you sure that String s = new String(“Avi”); automatically creates string object in SCP? I dont think this is true because then the concept of “Interning” string objects of heap into SCP would then be unnecessary.
    Kindly respond.

  • @nagarajsindhe1832
    @nagarajsindhe1832 6 лет назад +1

    Hi can you please upload a video for spring, maven and junit test integration with this web app using some use case with database, ex : online movie booking and cancellation

  • @sudharsankarra951
    @sudharsankarra951 5 лет назад

    String s="sudarshan";
    String s1="varun";
    String s="damodhar";
    Sysout(s);
    what it will going to print please explain this?

    • @ziyadbeg1821
      @ziyadbeg1821 5 лет назад +1

      Compile time error we cannot create object with duplicate name

    • @nissisenthil
      @nissisenthil 4 года назад

      It will print damodhar because s will reference to damodhar when you give String s = " damodhar"

  • @akshaynagawade2644
    @akshaynagawade2644 5 лет назад

    Which operation's are run-time and what other?how?

  • @swarnalatha8108
    @swarnalatha8108 3 года назад

    How string will work in multithreading

  • @akulabhaskar3797
    @akulabhaskar3797 6 лет назад

    Hello Avi its nice ,Will be much better if you can explain same in compiler .

    • @SeleniumExpress
      @SeleniumExpress  6 лет назад

      Sure, I will put it's practical soon.
      Have a nice time !!

  • @testodoo9139
    @testodoo9139 4 года назад

    Try to make it short videos .. taking so much time to explain the concepts

  • @jonwinder1861
    @jonwinder1861 4 года назад

    This is also the reason why rename refactor works as it does

  • @devkawde831
    @devkawde831 3 года назад

    Bro, garbage collector don't access String pool area,you said object is eligible for garbage collector

  • @anonymous8038-c4m
    @anonymous8038-c4m 6 лет назад

    Great man....

  • @Rajnish089
    @Rajnish089 6 лет назад

    I have a small question related to intern() API. As you said that this API forces the JVM to point the address available in SCP even though we use the new keyword. Can you please help me to understand, String s= new String("Rajnish").intern(); Is that the memory created in heap area is ready for GB collection.

    • @SeleniumExpress
      @SeleniumExpress  6 лет назад

      Rajnish Sharma Yes absolutely, the object which was created in heap will be no more in use as u have used intern().
      So it will be ready for garbage collection

  • @kavie8257
    @kavie8257 6 лет назад

    Hi,
    Thanks for the tutorial
    str2.concat("lash") has to be in String Constant Pool,not in Heap right?

    • @manasranjan5232
      @manasranjan5232 6 лет назад

      "Lash" will be created in the scp are as it is in literals.but avilash will be created in heap are as we are using concat() and it is a runtime operation only if it has a reference like...... String s2=str.concat("lash").

  • @tusharsibal4799
    @tusharsibal4799 6 лет назад +1

    hi.. great content, but as you said a new object is being created in the heap section while using new String("Avi"). It means now the reference is not to the SCP so we should be able to mutate the string obj in that case. ??

  • @javawicode
    @javawicode 5 лет назад

    so why when i call hashCode on
    String s = new String("Abc")
    and Strin s2 = "Abc"
    hashcode and equals is true ? its same object, so ... there is not s on heap

  • @suyashsahu4546
    @suyashsahu4546 6 лет назад +2

    please make your videos a little bit shorter length...thanx

  • @vishalgaikwad873
    @vishalgaikwad873 6 лет назад

    sir can you make video on .equals() and hashCode or explain it

    • @SeleniumExpress
      @SeleniumExpress  6 лет назад

      yah sure, I am working on it right now. Will be published soon.
      Thank you so much for suggesting..

  • @Rajnish089
    @Rajnish089 6 лет назад +1

    Hi Avi, Its long we have not heard you. What's the next you are uploading for your student? Missing your videos.

    • @SeleniumExpress
      @SeleniumExpress  6 лет назад +1

      Hi Rajnish, hope you are doing well . I am a little held up with work. I will be uploading soon.

  • @aswathyramesh1574
    @aswathyramesh1574 5 лет назад

    what will happen if I give str2=str2+"lash"?

  • @siddhantjaiswal3077
    @siddhantjaiswal3077 6 лет назад

    Mast

  • @prernatayade6259
    @prernatayade6259 5 лет назад

    u r awesome

  • @thannasip8001
    @thannasip8001 5 лет назад

    make video short it takes long time but its not required