String important points

String s1=”java”;
String s2=”coder”;

//Sop means System.out.println(for print)

Sop(s1+s2); //output-javacoder

Sop(s1+10); // java10
//10 is treated like a string.

Sop(s1+10+20); //java1020

Sop(10+20+s1); //30java
//First 10 and 20 were added and then 30 concat with s1.

note-Left to right operation takes place with the plus operator … first addition will happen and then concat.

Sop(10+s1+20); //10java20

Sop(s1+20/10); //java2
//First division took place and then concat method was used

Note–BODMAS rule is used in Java … if you do not know the bodmas rule then do a Google search.

Sop(s1+10-5); //error

//first s1+10 =java10
then java10-5
java10 -5 is not possible, so we will get error.

If you found this post useful, then follow me️

原文链接:String important points

© 版权声明
THE END
喜欢就支持一下吧
点赞14 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容