Thursday, 8 December 2011

class file in java : representation of your data in class file ( try it ) !!


hello friends its cold in ma country and this topic is hot because we are dealing with java { hot-coffee } . see , people think that they can not use or they can not find any-thing from the class file but , i think you can find anything if you are serious for that thing specially in a java program . today i can say that if a person like me who is poor in studies can find some-interesting thing specially in java than any-one in this world can do anything specially in java . an advice from ma side is that , just devote your life to some topic or some fields than seriously you can feel the power of that special field .
today i am just explaining one topic because i just use ma 3-days in only in this topic and still i am not perfect so i think life is not created for being perfect its just created by god to try to be a perfect man . i respect god because he gave me a opportunity to give some-thing special to this earth . and still i am trying for providing some-small things at this level but i am glad because i just make a start , & seriously after some years  i will give more things to this earth .
see now come in a topic , i have a java program here i just enter a string and i am trying to find that how data is represented inside array .

here in image i have just enter a string and trying to find out how it is represented in the class file . for this i am using ” getBytes() ” method by this method your string is converted into the bytes and these bytes are represented and stored into the arr_1 [ ] and i have just printed that data with “Sytem.out.println()”  and see after it you will find the output in the UTF-8 format because inside get-bytes we are using it & the key point is that the UTF-8 format is same as ASCII format because every thing is entered by you from key-board is same as ASCII format thats why in next image i just converted data into hexa-decimal form .

now the interesting thing is that what will be my next step . for this i just use my class file and convert it into hexa-decimal form and in the hexa-decimal form i just find some great type of thing which motvates me and shows that i did it or i use my 3 days in a accurate way .


this image is croped but the main thing resides in this image and i think for me this is enough to explain . so the data in hexa-decimal is present in my class and this is the thing what i am trying to explain you . please try some-other example also , because java is infinite in  terms and in fields .
thanks for reading .


Wednesday, 7 December 2011

some hammering problems in java


some question , if you are a java programmer or java user .
1. why java provides minimum support to boolean variables .
2. why java supports only 255 dimensions in array .
3. why java supports only 255 parameters in a function .
4. why java uses 9999999 values as a diffrentiator in representing values in the form of E form and in normal form .      example :– 10000000 is represented like 1.0E7 and 9999999 represented normally 9999999.

Monday, 5 December 2011

run-time polymorphism in java .

if you are dealing with polymorphism in java than definitely at the start you will face the problem in the phase of run-time polymorphism . so do you ever think that what type of thing is happened at the time of run-time polymorphism . for this look at this picture ::--

in this figure i have just described the program , because we all deal with this type of programming in the phase of run time polymorphism , now think about the output of this program .


now think about this ... how this process is happening from the scratch or from the compile time , now see at this picture , this image is passed or this is the run_time_constant_pool which is passed after the compilation of the program .
so this text of information is passed at the time of run time see at the point 4 ... from point 3 ...
you can see that compiler told to jvm that there are two methods which are referencing from main-class(1) and support-class(2) . so at the compiler time methods are only checked that they are legal or illegal . and they are displayed or represented as legal .

now at the run time , we are taking run time because objects are created at run time and every linking is performed at run time .















Sunday, 4 December 2011

difference between jdk-6 and jdk-7

hello every one , these days , you can easily watch or feel the effect of java in the whole world 3 billion devices  are using Java , this is great for me . but do you know now java is under the fame of oracle . and if you download the jdk  from the site you find that they are over-taked by oracle .

now what is the difference between jdk-6 and jdk-7 , here i am sharing my views what i feel , because i tried the both and found some-great things inside jdk-7 . for a programmer if you are an people who just believe in programming , there are no difference because he never wants to deal with those affects and i found those difference because i am a blank person in this world who is living without aim .

so have you ever heard about run-time-constant pool . i think this pool is hurted mostly , because i think pool of jdk-6 and pool of jdk-7 is changed totally . the most important sun introduced in jdk-7 is UTF-8 format , which is compatible with ASCIZ representation ( same as ASCII , difference is : followed by null { zero byte } ) and the benifit of UTF-8 is that multi-lingual support and comfort in encoding .

you can feel or use the run-time-constant pool using :
        javap -verbose classfile ( without .java ) 

Monday, 28 November 2011

class file : please don't think that you can not find any thing from class file in java program .

today i think if 10 people are working in java than from these 10 people only 1 is working for his basics and rest 9 are only using java . i will tell you something ... i met some-one and he replied to me that he had completed his java in 30 days i am supprised and appreciate him that he did a great job , after he asked me what are you doing in java , i generally replied him that i am just using java , because i dont think you and say anything to these type of people .

some-people thinks that class file is a waste in java programming but , if you take my point or believe in me than seriously all days and nights i just use my time in working but now you will think what  a jerk i am ! yaa thats true that i am jerk and these types of words are also used by my brother for me .. i respect those words , because i deserve for those words .

now this is a class file now after this i will highlight some-points which are understand by me , and you can also understand them easily .


now here i just edited 4 points which are easy to understand .
so please look at them .

1. <init> is used for initializing the instance variable so it is called implicitly & in previous blogs you can watch the whole process of init .

2. now at second i just point the main method inside it there is a import type statement by which you can easily use string in java , so this import statement is differ from original statement because this is internal representation of jvm here we remove "." from "/" , and after it "V" is there "V" means void type .

3. now at 3 you can see that there are two methods name . so at the top only names are saved of method , and stored into string pool and when ever they are needed they are fetched from the string pool .

4. and at 4 there is a source file name .








Wednesday, 23 November 2011

How things are initialized in java program inside jvm ..

hello every one i am tushar , good morning to all of you ,i m from india the best country of this world . and its honor to me that i am indian and writing blogs for my love 'java' . and today i am dealing with " How things are initialized in java program inside jvm  .. " .


so for me programming is not important , i love my state when i deal with basics . so in java i always prefer basics , than programming because basics are the the root of everything . so thats why i always deal with jvm specification .


when we perform or implement any-thing inside java program . every thing in initialized thats why initialization is the first step of every process . so inside java/jvm we have two statements for initialization they are <init> & <clinit> . 


<init> :---- this statement is used for initializing the instance       variable of java program . 


<clinit> :-- this statement is used for initializing the class type variables in a java program .


now think about what will happen in this case .
now what will happen for this program , now do you ever think that how things are initialized means its lies inside the instance variable category but these are initialized at static variable but we have only two initializer <init> and <clinit> 
and they are found inside jvm so the question rises is , how can you say that " int a = 10 and double d = 29 " can initialized at the compile time . so for this java/jvm operate this problem by constructor and initialized them inside constructor . like ...


now it is clear that no matter where you initialized values of instance variables , every thing is initialized in constructor if you are declaring them as a instance variables . 

                                                  .thanks tushar

Sunday, 20 November 2011

real example of ...which loop is better "for or while" in performance .

hello friends its morning in india , so very good morning to you and thanks to god for providing me a great life .

when i am dealing with " which loop is better for or  while in performance " i found some difficulties but after every stairs surely you get one step closer to your destiny . so lets start with the program but before this here i use a method " System.nanoTime() " which help me the most in finding the difference between for and while .




now these three methods are used like this .

image : 1 --

image : 2 --




here we find the actual time after initialization loop means for ( int i = 0 ; i < 10 ; i++ ) ; so from this program i  found some key points related to performance of loop . these points are following .

1 . the loop which holds the property of initializing takes more time than the other loop which holds the property of only iteration .

2. and after one iteration the loop which holds the property of initialization and the loop which holds the property of only iteration takes nearly equal time 

3. after 37 tries with the help of do-while loop , both loop takes nearly half time of its initialization time .

so if you want to test this program in real machine than please switch to p-2 or p-3 processors because i am using i-3 and finding the accurate result in this machine is very hard for me . so best of luck and the whole program is added ...