Java: Amazing Interesting and Cool Tricks Part -1 ๐๐๐๐✌
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 - ๐๐๐
System.out.println(0123);
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๐๐.
+ 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
2-intern()
public class Javaoneworld { public static void main(String args[]) { String str1 = new String ("javaoneworld"); // String str2 = new String ("javaoneworld"); /* * as we initializing str1 and str2 with new keyword so they will not share the * same memory pool */ System.out.println(str1 == str2); //false /* * using the intern() method we can force both the string to share same memory * pool */ str1 = str1.intern(); str2 = str2.intern(); System.out.println(str1 == str2); //true } }
2- Comment
As we all know we use comments to not execute the code,
where we use comment, compiler skips that line.
In java we have two types of comment
//single line comment
/* multi line
comment*/
But what if I want to execute the line which is even commented?
can we achieve this?
Yes , here is a way to achieve this๐๐
public class Javaoneworld { public static void main(String args[]) { // \u000d System.out.println("Javaoneworld"); } }
This comment will execute successfully because of Unicode character that we appended, java compiler will parses this “\u000d” Unicode character as a new line. Java allows using Unicode characters without encoding.
Find another must-read post.
Thanks a bunch for being here.
#stayhealthy
#takeCare







Thank you for sharing these tricks. This is such a great resource that you are providing and give it away for free. I love seeing blog that understand the value of providing a quality resource for free. Great blog. Data structures and algorithms in Java solutions
ReplyDeleteF6F6D1FAA0
ReplyDeletekiralฤฑk hacker
hacker arฤฑyorum
kiralฤฑk hacker
hacker arฤฑyorum
belek
D776DECF
ReplyDeleteForum
Forum
Forum
Forum
Forum
Forum
Forum
Forum
Forum