Sunday 8 April 2012

in java , memory for strings allocation is performed inside fixed location !


hello every one , after a long time i am writing post but i am not a good writer but please understand this topic , i am interested in writing blogs but before my interest , it is necessary to explore the concept behind memory allocation for strings , so why i am saying this , this is the point !
i am working with string and i just find a hashCode() method , and i just find the hashcode() of "zzzz" and "zzza" and between this i found relation , that the difference , between their hashcode() depends upon their ascii code , and after it i recompile it and try to find out , the dynamic allocation of memory for "aaaa" and "zzzz" , so the hashcode() generated for these two strings is always same . 
so every string which have length == 4 lies between ... 1477632 to 387884 { entered from keyboard }
now the question in your mind will arise that how i am finding this range see the ascii table from wikipedia "http://en.wikipedia.org/wiki/ASCII"  so from this we get the characters entered from the keyboard !
now how this thing knocks in my mind , i am performing this thing which is displayed in this picture 

so jvm uses dynamicness but it stored fixed position in storing things !

No comments: