String important points

anandsingh8

Anand Singh

Posted on September 29, 2020

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❤️

💖 💪 🙅 🚩
anandsingh8
Anand Singh

Posted on September 29, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

String important points
java String important points

September 29, 2020