DEV Community

JavaOneWorld
JavaOneWorld

Posted on

Some cool tricks in Java

Java☝:: A most beautiful and powerful programming language👌.

as much as you'll deep dive into Java you'll learn something new.

Here are some Amazing and cool trick's -

1-

Do you know what will be the output of the below statement? 👇

System.out.println(0123);
o/p = 83 but why?

Click on Below - 👇👇👇

https://www.javaoneworld.com/2020/05/why-output-of-012-is-10-and-0123-is-83.html

2- Java String

Concatenation - concat() Vs the + Operator

concat() --

if want to concat str1 with str2 where str1 is null.

str1 = null;
str2 = "javaoneworld";

str1.concat(str2);

you'll get NullPointerException👎👎.
Enter fullscreen mode Exit fullscreen mode
  • Operator --

if want to concat str1 with str2 where str1 is null.

str1 = null;
str2 = "javaoneworld";

str1+str2;

you'll not get NullPointerException instead you'll get some  output😅😀.

o/p - nulljavaoneworld
Enter fullscreen mode Exit fullscreen mode

Follow the below beautiful url for some more cool tricks.

How to execute commented code? and more.
Enter fullscreen mode Exit fullscreen mode

https://www.javaoneworld.com/2021/07/java-amazing-interesting-and-cool-tricks.html

Thanks a bunch for being here.

stayhealthy

takeCare

stayCode

programming

coder

code

happycoding

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

AWS Q Developer image

Your AI Code Assistant

Ask anything about your entire project, code and get answers and even architecture diagrams. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Start free in your IDE

👋 Kindness is contagious

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

Okay