DEV Community

Anand Singh
Anand Singh

Posted on

2 1

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

Top comments (1)

Collapse
 
peledzohar profile image
Zohar Peled • Edited

At first I thought to myself - Well, maybe Java's compiler is that dumb, no way C# will allow this! I had to try...

Implicit conversions

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay