Crazy tricks in Java 2022

Crazy trick in java

Java is a high-level oop (object oriented programming) language, which was developed by Sun Microsystems in 1991. It's initial name was oak. It is mainly used in Android and web development. Java is a kind of language developed by the developers for what time demanded. At that time C language family was very famous that's why java is kind of similar to C.

Now lets talk about some tricks in Java language that will make your tasks easier. We suggest to use a IDE for it.

1.) Class and Datatypes(Wrapper):- In the print statement when we wrap the value of num like wrapnum then if we compare them then the boolean vale will be false As the objects are getting compared and the values are not getting compared so the result will be false.

2.) Comment execution:- Normal developers and programmers thinks that comments in any programming language are not executed but that is not the case we can execute the comment in java but by apply a trick for eg. "// \u000d System.out.println("CodinByte");" , by putting \u000d we are telling the machine to execute this line if it is valid. The Program will run without throwing any error or warning smoothly.

3.) Using Underscores in Numerical datatypes vars:- After the release of Stable Version 7 and later versions you can put and use `_` in a variable declaration in a program, like "int t = 6969_6969" then when you will print it you will se the output as 69696969.

4.) Multiline comment:- Now as I already said comment can also be executed if we put "\u000d after the //, but we can also execute multiline comment with this trick if we want to fool anyone that it is a comment then we can use /* and */ to start and close the multi line comment.

5.) Loop that is infinity:- When you use the command "javap -c ClassWithThoseMethods" in for and while loop you will get an interesting output. You must try it.

Hope you liked this article comment down below what trick amazed you the most.

Post a Comment

Previous Post Next Post