Monday, 23 April 2012

difference between two most toString() methods in java !

hello every one java is based on strings , means every thing which you see is presented by strings , and every thing is presented with the help of  "toString()" method . now see why this thing arose in my mind !



at the time of coding , i implement this easily but at the time of  run-time i found something which does not suits in my eyes so i tried to found the reason behind that output , but before this see the output !


see there are 4 lines and each one in presenting their output according themselves , but why , what is the problem with "System.out.println(xxx.toString());" , but the point is that there are few things which are noticeable in seeing , that ::
1st line is output of reference.toString() ;
2nd line is output of only class variable ;
3rd and 4rth are different from 1st one , 3rd and 4rth are output of  String.toString() ;

so , definitely the problem or solution is situated in the toString() method of reference classes , means toString() of String and toString() of now_my_own_rules class , now look at the two different methods of both classes .

first look at the toString() method of String class .


see the lined area , and see the line which is put inside the two black boxes , means when ever you enter any string in any String object , it will return the string itself .


now also see the , the lines added inside the boxes , here you will find the String representation of object , but here i override the toString() method thats why it is printing something else , otherwise it will print the class_name@hexadecial values ..


thanks ,
tushar ..

Friday, 20 April 2012

what is the problem with equals and == !

see in java , great thing about string is that , string is primary concept in java , means every thing in java is presented by string , you want to print something , you want to show someone that they have created that thing at that time you also need strings , every api is added with the help of strings { means you use text }.

now see two great points about strings . " equals " .......  " == " ! but i am here to show or placing the problems introduced by "equals" and "==" but before this understand why we use them , 

Equals ::  equals always deals with the content present in the object , now look at this , 


see if you use equals it will deal with 
::: pillion seat 
::: light 
::: tyre 
::: glass

" == " ::  now we have "==" in java , it will deal with who is holding , means if EARN is having that car of DUKE have that car ! "==" compares the reference , look at this .


Problem associated with "EQUALS" and "==" :: now the main points comes in , see we have two human "duke" and "earl"  now a car is standing in parking and earl takes duke's car and went to market for buying something now duke comes in parking and search his car , and did not find his car and after sometime he saw that earl is using his car , after it they fight with each other , now think how they will solve their problem by "equals" and "=="  



now "DUKE" and "EARL" use 

 ::: "equals" for solution and find that and find that they use same content glass , pillion seat , tyre .

 ::: "==" for solution and finds that they use same car , and drive same car 

so in the end , they have no solution and still they are fighting , so we have to override our "equals()" in java .


 

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 !

Monday, 30 January 2012

How cursor moves in your mobile screen .

Hello friends these days i am working or dealing with mobile application development , so i found something typical but it is very easy , now first why it is typical , because when for this i read some articles but if i say a term that google has nothing for J2ME so you have to create your own things .

when i found this article "http://www.java-samples.com/showtutorial.php?tutorialid=727" i am happy that some one is in net who can help developers , thanks to JAVA-SAMPLES , but i am not satisfied with their example , if you are a developer and you need something special than scratch your itch and seriously after scratching you will found that you have something different .

lets have a look of ma code ,  


now we have handleAction( ) , in our code  and now main task is started  , means thats what i want to explain

now here is something interesting , interesting in terms means x and y variables these two variables are used for increasing mouse speed now how x and y variables are used for increasing cursor speed .

now what is the use of drawline ( ) , see draw line is used for drawing the cursor , now drawing means every time you press your key for moving cursor and for this we are using x and y variables and after setting your next postion using x and y we are drawing image or cursor at that place .

now other two variables x_axis and y_axis . i have used these two variables in selecting some icon , means i have displayed a image in , and with the help of x_axis and y_axis variable i can easily select any portion of ma mobile with the cursor .



Tuesday, 24 January 2012

When you press some key in your mobile , screen shows its reflection , but how ?

hello friends its important to all of us to understand what is happening in-front you and still you are unknown from these things . see today i am explaining a thing which is or which can describe or can makes your doubts clear that " When you press some key in your mobile , screen shows its reflection , but how ? " .

see this is our mobile keys .

see this is not ma mobile keys its is suns microsystem's default phone for testing your applications , but we all know that our phones has all these keys , now when ever we press some key we see its result in our phone screen .

now my field or point start that , if you press 1 than 1 will display in your screen and when you press 2 , 2 will display in your screen but how these things are working , and the fact comes that you can also perform calculation in your phone or in your device .

now so , it is same like our keyboard with monitor means you are pressing some key in your keyboard and your screen or monitor is showing the display , and we all know that UNICODE the mood changer , the universe of characters is helping you or all of us in our coding scheme . but but , the point comes when you press a key whose unicode is not present . than the problem arise so that is the point what i want to explain .

now you have every code for these buttons , and for these you can use ASCII character scheme , but after EUROPE other countries , are also creating their mobile and entering their own character set . so we need or introduced a charset known as UNICODE .

now we have these keys in our mobile phone and i want to ask how these keys are operated or handled in our mobile system or by our mobile machine . but you can easily see that the other keys are handled by unicode means now your every positive value is added to some language , means every positive value is used for some character which is in some language . so now we have negative numbers , now you will rise a question that how negative values are handled .

see how key reflection is performed .
 
 now how these other keys which have blank key code are operated by mobile or our machine .


so thanks ....
 




Wednesday, 18 January 2012

how your mobile application is handled by softkeys .

hello friends ,  time of the day is changed and its AM in ma watch and posting or dealing with a interesting topic , these days after a long time , i am dealing or working in mobile applications . so i found something interesting , means something interactive which is used by all of us , in our daily life " how your mobile application is handled by softkeys . "

it is not very hard because we are comfortable with mobile and every day we use our mobile & specially our mobile applications . so what happen when you use your mobile applications and handle it .

so my question or my post is pointing some basic things which are hidden or added in some books , so who is not interested in developing mobile applications can not understand this concept so i tried my best to explain this properly . so friends , if you are interested than please go for JAVA & friends if you are in love with any language than i think you are the happiest person in this person .

so when ever you open some application in your phone ( touch or simple ) than , you will find two options in your screen , and so first how this options are created in your mobile screen and why they are always added at the same place .

now the real topic , comes in the field , please read this image very carefully and understand properly . 


 .... thanks

Saturday, 14 January 2012

how overloading and overriding is performed

hello everyone after a long time i am writing a post , i think it is very important to understand that how overriding is performed .

OVERRIDING ::

over-riding means , you are hiding something if you talk or want to understand in my language , but the previous thing which i said that hiding is not totally hided it maintains its status and state .





now this image is the perfect example for overriding . 
 


for this if you ever use or deal with java runtime environment than i think it is easy for you to understand , so when ever a call is created at that time a frame is created , and inside that frame the information is added , now what is that information .


so this information is passed in "this" and added to first position at the stack now our caller can easily find the method , i think it is easy but the problem arises when display does not occur in the sub_class ,



now another problem arises :: this problem looks like ...





how main_class ob = new sub_class ( ) ; will performed .



OVERLOADING ::

now we have to deal with overloading , before i explain you every thing please take a suggestion of mine that , when ever in your life you are dealing with overriding or with overloading than please use a stack of each and ever class inside of your mind , and i think any problem related with related with overloading and overriding can be solved easily .

now i am saying that you have to deal with "stacks" create a stack for each and every class and than solve your problem . take a example ::


now what ever code you write , it is handled easily by the stack , now how handling is performed .


so when ever you find problem like this , it is confusing for new people because it is too much same as overriding , but now my point come what i want to explain . because i never think that a definition of some point can play a important role or game in a real field .





so overriding means  :: same signature .
and overloading means :: different signature .


 and same signature is differentiated at run time because at compile time you can not differentiate so thats why you can create two same methods in a same scope and overloading deals with different signature and thats why the differentiated at the compile time so .

OVERLOADING == EXACT MATCH .
OVERRIDING == RUN TIME MATCH MAY OR MAY NOT EXACT .