Alshifa Hasnain has Published 283 Articles

When to use the ofNullable() method of Stream in Java 9?

Alshifa Hasnain

Alshifa Hasnain

Updated on 10-Jun-2025 18:39:17

2K+ Views

In this article, we will learn to use the ofNullable() method of Stream in Java 9. We will first go through the Stream class, after that we will learn about the ofNullable() method along with its syntax and real-world use cases. Stream Class Stream was introduced in Java 8, the ... Read More

How to load a file into the JShell session in Java 9?

Alshifa Hasnain

Alshifa Hasnain

Updated on 09-Jun-2025 19:30:05

2K+ Views

In this article, we will learn to load a file into the JShell session in Java 9. We will learn about Jshell and different ways we can load a file in Jshell, which is the command line and the /open command. What is a JShell? JShell is a new command-line ... Read More

How to implement a lambda expression in JShell in Java 9?

Alshifa Hasnain

Alshifa Hasnain

Updated on 09-Jun-2025 19:29:50

355 Views

In this article, we will learn to implement a lambda expression in JShell in Java 9. We will learn the syntax, explain the working of lambda expressions, and how they work with functional interfaces, and give examples with the JShell environment. JShell JShell is Java's first REPL and command-line ... Read More

What are new methods added to the String class in Java 9?

Alshifa Hasnain

Alshifa Hasnain

Updated on 09-Jun-2025 19:29:15

263 Views

In this article, we will learn about the new methods added to the String class in Java 9. We will learn about Strings and the new methods in the String class, along with examples. Strings A String is the type of object that contains a collection of characters enclosed by ... Read More

What will happen when we try to override final method of the superclass in Java?

Alshifa Hasnain

Alshifa Hasnain

Updated on 09-Jun-2025 14:49:19

2K+ Views

Any method that is declared as final in the superclass cannot be overridden by a subclass. If we try to override the final method of the super class, we will get a compile-time error.  Rules for Implementing Method Overriding The method declaration should be the same as that ... Read More

How can we create an unmodifiable Map in Java 9?

Alshifa Hasnain

Alshifa Hasnain

Updated on 09-Jun-2025 14:28:11

421 Views

In this article, we will learn to create an unmodifiable Map in Java 9. First, we will learn about Map and Unmodifiable Map and after that we will be knowing the different ways through which we can create an unmodifiable map (Map.of method and unmodifiableMap() Method). Map In Java, a ... Read More

Differences between orTimeout() and completeOnTimeOut() methods in Java 9?

Alshifa Hasnain

Alshifa Hasnain

Updated on 09-Jun-2025 14:27:47

2K+ Views

In this article, we will learn about the differences between the orTimeout() and the completeOnTimeout() methods in Java. Both the orTimeout() and completeOnTimeout() methods are defined in the CompletableFuture class, and these two methods were introduced in Java 9. CompletableFuture class The CompletableFuture class, introduced in Java 8, represents a ... Read More

How can we change the background and foreground color of a JTooltip in Java?

Alshifa Hasnain

Alshifa Hasnain

Updated on 09-Jun-2025 14:27:05

362 Views

In this article, we will learn to change the background and foreground color of a JTooltip. We will be using UIManager.put(), we customize the tooltip for a JLabel by setting a white background and green text, which will improve the appearance of the default tooltip. What is a JToolTip? A JToolTip ... Read More

How can we implement a rounded JTextField in Java?

Alshifa Hasnain

Alshifa Hasnain

Updated on 09-Jun-2025 14:20:34

3K+ Views

In this article, we will learn to implement a rounded JTextField in Java. The JtextField is rectangular in shape, and to create a custom JTextField with rounded corners, we will use the RoundRectangle2D class and with the help of fillRoundRect() and drawRoundRect() methods in Java Swing. What is a JTextField? ... Read More

How can we show/hide the echo character of a JPasswordField in Java?

Alshifa Hasnain

Alshifa Hasnain

Updated on 09-Jun-2025 14:20:00

2K+ Views

In this article, we will learn to show/hide the echo character of a JPasswordField in Java. The password in this will be hidden with *. And we will be using the setEchoChar() method to toggle between hidden and visible text in a Swing based application. What is a JPasswordField? A JPasswordField ... Read More

Previous 1 ... 3 4 5 6 7 ... 29 Next
Advertisements