
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 7442 Articles for Java

10K+ Views
In this article, we will learn to use the readAllBytes() method of InputStream in Java 9. We will get to know the readAllBytes() method with its syntax, then we will learn about the InputStream Class with its methods, and lastly, we will learn the use of readAllBytes() with an example What is the readAllBytes() Method? In Java 9, the readAllBytes() method reads all bytes from an InputStream object at once and blocks until all remaining bytes have been read and the end of the stream is detected, or an exception is thrown. It returns a byte array containing the ... Read More

2K+ Views
In this article, we will learn to get dates using the LocalDate.datesUntil() method in Java 9. We will learn about date ranges, skip or limit results and by using the Period class we will apply the custom steps. What is a LocalDate? LocalDate is a part of java.time package and is an immutable, date-time object, which often represents a date in the "year-month-day" format. For example, the value of "2nd May 2025" could be stored in a LocalDate. The following are the maximum and minimum values of the LocalDate: MAX: The maximum supported LocalDate, '+999999999-12-31'. ... Read More

544 Views
In this article, we will learn to get the date and time in JShell in Java 9. First, we will learn about the date and time class in Java with an example, and after that will learn about date and time in JShell with multiple examples. JShell JShell is an interactive command-line tool that allows us to learn, investigate, and explore the Java language and its API. We can type any valid Java code into the console and get immediate results without the need to write a verbose class with the main() method. C:\Users\User>jshell | Welcome to JShell -- Version ... Read More

2K+ Views
In this article, we will learn to use the collect() method in the Stream API in Java 9. Java Stream API collect() Method In Java, the collect() method in the Stream API collects all objects from a stream object and stores them in a type of collection. The user has to provide what type of collection the results can be stored. We specify the collection type using the Collectors Enum. There are different types, and different operations can be present in the Collectors Enum. Syntax The following is the syntax for the collect() method declaration: R collect(Collector

356 Views
JShell is a REPL interactive tool introduced in Java 9 to execute and evaluate simple Java programs like variable declarations, statements, expressions, and programs without using the main() method.In this article, we will learn to create scratch variables in JShell in Java 9. Variables in JShell In Java 9, JShell allows for the declaration and use of variables without the need for a surrounding class or method structure. One may be able to explicitly declare the variable with a type, or else it might be declared implicitly using var for type inference. C:\Users\User>jshell | Welcome to JShell -- Version 9.0.4 ... Read More

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 interactive REPL (Read-Evaluate-Print-Loop) tool introduced in Java 9 to evaluate declarations, statements, and expressions written in Java. This tool also allows us to execute Java code snippets and get immediate results. Loading a file into the JShell There are two ways to load a file into the JShell session in ... Read More

459 Views
What is JLink? Java Linker is a new linker tool that has been used to create our own customized JRE. Usually, we can run our program using default JRE provided by Oracle. If we need to create our own JRE then use this tool. JLink tool can help to create its own JRE with only the required class to run the application. It can reduce the size of the API developed and the dependency of using the full JRE. In Java 9, we have a new phase between compiling the code and its execution, link time. Link time is an optional phase between the phases of ... Read More

2K+ Views
The transferTo() method has been added to the InputStream class in Java 9. This method has been used to copy data from input streams to output streams in Java. It means it reads all bytes from an input stream and writes the bytes to an output stream in the order in which they are reading.Syntaxpublic long transferTo(OutputStream out) throws IOExceptionExampleimport java.util.Arrays; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; public class TransferToMethodTest { public void testTransferTo() throws IOException { byte[] inBytes = "tutorialspoint".getBytes(); ByteArrayInputStream bis = new ByteArrayInputStream(inBytes); ByteArrayOutputStream bos = new ... Read More

365 Views
In this article, we will learn about the control flow statements in JShell in Java. JShell is a new interactive command-line tool introduced in Java 9. This tool can also be called REPL (Read-Eval-Print-Loop) because it takes input, evaluates it, and returns output to the user via the command line. JShell Control Flow Statements Control flow statements are used to control the execution path of the code and are a fundamental part of the Java programming language. We can execute multiple-line control flow statements using JShell in the same way as Java. It recognizes multiple-line statements are prompts with the ... Read More

692 Views
An important feature introduced in Java 9 is Module. By using a module, we can divide the code into smaller components called modules. It means each module has its own responsibility and declare its dependency on other modules to work correctly.Below are the steps to create a modular project in Java 9:Initially, we can create a file named "module-info.java" and add to a package(module) for which it is created. For instance, if our package name is com.mycompany.mypackage then the file goes to the same package (src/com.mycompany.mypackage/module-info.java). We can create a module by declaring "exports" and "requires" expressions.If our modules require another module ... Read More