Raja has Published 760 Articles

How to remove the HTML tags from a given string in Java?

raja

raja

Updated on 01-Jul-2020 07:57:01

18K+ Views

A String is a final class in Java and it is immutable, it means that we cannot change the object itself, but we can change the reference to the object. The HTML tags can be removed from a given string by using replaceAll() method of String class. We can remove the ... Read More

Importance of the parseBoolean() method in Java?

raja

raja

Updated on 01-Jul-2020 06:13:23

112 Views

The parseBoolean() method is an important method of a Boolean class. The parseBoolean() is a static method and can parse the String method argument into a Boolean object. The parseBoolean() method of Boolean class returns the boolean represented by the string argument.Syntaxpublic static boolean parseBoolean(String s)Exampleimport java.util.Scanner; public class ParseBooleanMethodTest { ... Read More

What is the importance of a WindowListener interface in Java?

raja

raja

Updated on 30-Jun-2020 13:32:30

206 Views

The class which process the WindowEvent needs to be implemented this interface and an object of this class can be registered with a component by using addWindowListener() method.Methods of WindowListener InterfaceThe WindowListener interface defines 7 methods for handling window eventsvoid windowActivated(WindowEvent we) − Invoked when a window is activated.void windowDeactivated(WindowEvent we) − ... Read More

What is the order of execution of non-static blocks with respect to a constructor in Java?

raja

raja

Updated on 29-Jun-2020 12:06:53

2K+ Views

Whenever an object is created, a non-static block will be executed before the execution of the constructor.Non-Static BlocksThe Non-static blocks are class level blocks which do not have any prototype.The need for a non-static block is to execute any logic whenever an object is created irrespective of the constructor.The Non-static blocks ... Read More

Can a method local inner class access the local final variables in Java?

raja

raja

Updated on 29-Jun-2020 11:12:53

688 Views

Yes, we can access the local final variables using the method local inner class because the final variables are stored on the heap and live as long as the method local inner class object may live.Method Local Inner ClassA local inner class instance can be delivered as an argument and retrieved from ... Read More

How to print pid, info, children, and destroy processes in JShell in Java 9?

raja

raja

Updated on 03-May-2020 09:53:31

108 Views

JShell is a Java Shell tool used to execute simple java statements like classes, methods, interfaces, enums,  and etc.. evaluates it, and prints the result in a command-line prompt.Java has improved Process API to manage and control operating system processes. ProcessHandle interface identifies and provides control of native processes, methods to check ... Read More

How to get system properties in JShell in Java 9?

raja

raja

Updated on 02-May-2020 11:09:29

298 Views

JShell is a REPL (Read-Evaluate-Print-Loop) tool used to execute simple statements, evaluates it, and displays the result without a main() method. We can start it by simply type "jshell" in command-line prompt.We need to get the system properties by using System.getProperty() and System.getProperties() methods.In the below code snippet, we can able ... Read More

How to implement JShell using JavaFX in Java 9?

raja

raja

Updated on 02-May-2020 09:45:07

178 Views

JShell is an interactive tool used to implement sample expressions. We can implement JShell programmatically using JavaFX application then we need to import a few packages in the java program listed belowimport jdk.jshell.JShell; import jdk.jshell.SnippetEvent; import jdk.jshell.VarSnippet;In the below example, implemented a sample Java FX application. We will enter different values in ... Read More

How to implement HashMap, LinkedHashMap, and TreeMap in JShell in Java 9?

raja

raja

Updated on 01-May-2020 17:24:58

134 Views

JShell is a command-line prompt tool introduced in Java 9, and it is also called a REPL tool to evaluate simple statements, executes it, and print the output immediately.A Map interface specifies a contract to implement collections of elements in the form of key/value pairs. Java collection classes that implement the Map interface are ... Read More

Differences between CompletableFuture and Future in Java 9?

raja

raja

Updated on 01-May-2020 11:45:14

5K+ Views

CompletableFuture class implements Future interface in Java. CompletableFuture can be used as a Future that has explicitly completed. The Future interface doesn’t provide a lot of features, we need to get the result of asynchronous computation using the get() method, which is blocked, so there is no scope to run multiple dependent tasks in ... Read More

Advertisements