Raja has Published 760 Articles

How to get stack trace using thread in Java 9?

raja

raja

Updated on 23-Apr-2020 12:19:48

362 Views

Java 9 has added StackWalker class to provide a standard API for accessing the current thread stack. In the previous java versions, we can use Throwable::getStackTrace, Thread::getStackTrace, and SecurityManager:: GetClassContext provided methods to obtain the thread stack.Thread.getStackTrace() method will return an array of stack trace elements representing the stack dump ... Read More

How to use intermediate stream operations in JShell in Java 9?

raja

raja

Updated on 23-Apr-2020 09:49:02

217 Views

JShell is a tool introduced in Java 9, and it accepts simple statements like expressions, variables, methods, classes, etc.. as input and produces immediate results.A Stream is a sequence of values. An intermediate stream operation is an operation that takes a stream. For instance, it can be applied to a lambda expression and ... Read More

How to implement java.time.LocalDate using JShell in Java 9?

raja

raja

Updated on 22-Apr-2020 17:32:06

447 Views

JShell is a REPL (Read-Eval-Print-Loop) interactive tool introduced in Java 9 that takes input, evaluates it, and returns output to a user.java.util.LocalDate class provides a number of methods to retrieve Date information: Day/Month/Year and related attributes Date meta-information: Classification-related information such as whether a leap year, etc. LocalDate class is immutable, and we can ... Read More

What are the rules for the Publisher interface in Java 9?

raja

raja

Updated on 22-Apr-2020 16:22:48

553 Views

A Publisher is a provider of an unbounded number of sequenced elements publishing them according to demand received from its Subscribers. Publisher interface is responsible for publishing elements of type T and provides a subscribe() method for subscribers to connect to it.public interface Publisher {    public void subscribe(Subscriber

How to implement relational and logical operators in JShell in Java 9?

raja

raja

Updated on 22-Apr-2020 11:11:58

111 Views

JShell has introduced in Java 9 that enables us to explore, discover, and experiment with Java language features, and extensive libraries.The relational operators (==, != , =) can be used mainly for comparison. It accepts operands of non-boolean primitive data types and returns a boolean value. JShell also supports logical operators that can be used in ... Read More

What are the rules for the Subscription interface in Java 9?

raja

raja

Updated on 22-Apr-2020 08:10:29

253 Views

A Subscription can be shared by exactly one Publisher and one Subscriber for the purpose of mediating data exchange. That is the reason subscribe() method doesn't return created Subscription, instead returns void. The Subscription is only passed to Subscriber through the onSubscribe() method callback. The Subscription interface contains two methods: request() and ... Read More

What are the improvements for @Deprecated annotation in Java 9?

raja

raja

Updated on 21-Apr-2020 18:23:10

84 Views

Any element that can be annotated with @Deprecated signifies that this particular element no longer be used for below reasonsUsing it is risky and may cause errors.May be incompatible in future versions.May be removed in future versions.A better and more efficient solution has replaced it.Java 9 has added two new ... Read More

How to declare multiple resources in a try-with-resources statement in Java 9?

raja

raja

Updated on 21-Apr-2020 14:46:32

1K+ Views

Try-with-resources statement has been improved in Java 9. If we already have a resource that is final or equivalent to the final variable, then we can use that variable in a try-with-resources statement without having to declare a new variable in a try-with-resources statement.We can declare multiple resources in a try ... Read More

How to implement integer type conversion in JShell in Java 9?

raja

raja

Updated on 21-Apr-2020 12:03:51

179 Views

JShell is a command-line interactive tool introduced in Java 9 version that allows the programmer to execute simple statements, expressions, variables, methods, classes, interfaces, etc.. without declaring the main() method.In JShell, the compiler warns the programmer about typecasting issues by throwing errors. However, if the programmer is aware of it, then explicit ... Read More

What are the rules for the Subscriber interface in Java 9?

raja

raja

Updated on 21-Apr-2020 08:38:18

294 Views

Subscriber interface subscribes to publishers to receive items through onNext() method, error message through the onError() method, or a signal that no more items to be expected through the onComplete() method. Before any of those things happen, the publisher calls onSubscription() method.public interface Subscriber {    public void onSubscribe(Subscription s);   ... Read More

Advertisements