Home » Java » Page 19

Java

Java 8 – How To Read A File?

A quick guide on how to read the file in older java and new JDK 8 version with example programs. 1. Overview In this tutorial, We’ll learn how to read a file line by line in java and print the files content onto console with example program. First, let us use the older java version for example demonstration and next ...

Read More »

Java 16 Records with JPA and jOOQ

Java Records The new Java version 16 includes a new feature: Records https://openjdk.java.net/jeps/395 “Enhance the Java programming language with records, which are classes that act as transparent carriers for immutable data. Records can be thought of as nominal tuples.” Let’s try Java records with JPA and jOOQ. JPA Constructor Expression One way to use projection in JPA queries is using the constructor expression. ...

Read More »

Looking into the JDK 16 vector API

JDK 16 comes with the incubator module jdk.incubator.vector (JEP 338) which provides a portable API for expressing vector computations. In this post we will have a quick look at this new API. Note that the API is in incubator status and likely to change in future releases. Why vector operations? When supported by the underlying hardware vector operations can increase ...

Read More »

Java 16: Stream.toList()

Java 16 introduces a handy new Stream.toList() method which makes it easier to convert a stream into a list. The returned list is unmodifiable and calls to any mutator method will throw an UnsupportedOperationException. Here is some sample code: 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 import java.util.stream.Stream; import static java.util.stream.Collectors.*; ...

Read More »

Compile and run java9 module program: part2

In the previous post we saw baiscs about java 9 modules like, what is module, how to create module project, module descriptor file and so on. In this blog we will learn how to compile and run java9 module program. Recommended read: Java 9 module details: part 1 Java9 Module example for hello world Before going further let’s take an ...

Read More »

Guidelines for Java code review

Having another pair of eyes scan your code is always useful. It’s helped me get better at writing cleaner code and spot mistakes faster. You need not be an expert to review someone’s code. Some experience with the programming language and a review checklist should help you get started. The following is a curated list of tips to keep handy ...

Read More »

Introduction into GraalVM (Community Edition): And How the Future Looks Like?

1. Introduction In this last part of the tutorial we are going to speculate about the future of GraalVM, both from the short-term and long-term perspective. I think there are three main themes which GraalVM is going to evolve: Improving native image technologyImproving and optimizing GraalVM JIT compilerImproving Truffle and including more Truffle languages Let us briefly talk about some ...

Read More »

Java Program to Add Two Numbers Without Using + operator

1. Introduction In this article, You will learn how to write a java program to add two numbers without using + or ++ operators. This looks quite interesting for freshers to think beyond their capability but it is very easy for mathematic lovers. Before that in the last tutorial, we have explained how to add two numbers in java and ...

Read More »

How To Make A File Read Only Or Writable In Java?

A quick guide on how to make a file read only in java using setReadOnly() method from File API. 1. Overview In this article, We’ll learn how to make a file as read only in java. After creating the file in java, we have to specify the file property readOnly flag to true. But, we can not set this flag ...

Read More »