tag:blogger.com,1999:blog-7258332205026269340.post9141109052554068206..comments2024-02-21T01:43:44.367-08:00Comments on Selenium-By-Arun: 47. Type conversionPriyanka Motoorihttp://www.blogger.com/profile/04643338373711611455noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-7258332205026269340.post-78599412929816445992015-06-04T05:03:17.614-07:002015-06-04T05:03:17.614-07:00@Preeti - You are right.
In the first case ->...@Preeti - You are right. <br /><br />In the first case -> System.out.println("a+b:" +a+b); <br /><br />+ is acting as a string concatenation operator i.e. "10" string text is concatenated with "0.21" string text. Hence 100.21 is printed.<br /><br />In the second case -> System.out.println("a+b:" +(a+b)); <br /><br />+ is acting as an addition operatorArun Motoorihttps://www.blogger.com/profile/18156045285817519369noreply@blogger.comtag:blogger.com,1999:blog-7258332205026269340.post-56642978882622312792015-05-27T10:19:17.284-07:002015-05-27T10:19:17.284-07:00For below pgm I am getting o/p as " a+b:100.2...For below pgm I am getting o/p as " a+b:100.21 " where as o/p should be a+b:10.21<br /><br />class PromotedType<br />{<br /> public static void main(String args[])<br /> {<br /><br /> int a=10 ; // a is on int type<br /> double b=0.21; // b is of double type<br /><br /> System.out.println("a+b:" +a+b); <br /><br /> }<br />}<br /><br Anonymoushttps://www.blogger.com/profile/00523600604003395791noreply@blogger.comtag:blogger.com,1999:blog-7258332205026269340.post-62029015855772866802015-03-20T00:04:30.244-07:002015-03-20T00:04:30.244-07:00@vastha - The correct output is 10.21. Please doub...@vastha - The correct output is 10.21. Please double check.Arun Motoorihttps://www.blogger.com/profile/18156045285817519369noreply@blogger.comtag:blogger.com,1999:blog-7258332205026269340.post-74827009162803219652015-03-19T23:23:14.745-07:002015-03-19T23:23:14.745-07:00In the different data type conversion like int a=1...In the different data type conversion like int a=10 and double d=0.21 Then a+d = 100.21 not 10.21.Please correct it in the output mentioned above.vathsahttps://www.blogger.com/profile/08266466332154266787noreply@blogger.com