Hello guys, you may know that from Java 5 onwards it's easy to left pad Integers with leading zeros when printing number as String. In fact, You can use the same technique to left and right pad Java String with any characters including zeros, space. Java 5 provides String format methods to display String in various formats. By using the format() method we can add leading zeros to an Integer or String number. By the way, this is also known as left padding Integers with zero in Java. For those who are not familiar with the left and right padding of String, here is a quick recap;
Ads 970x90
Tampilkan postingan dengan label java 5 tutorial. Tampilkan semua postingan
Tampilkan postingan dengan label java 5 tutorial. Tampilkan semua postingan
Rabu, 28 Juli 2021
The Ultimate Guide of Generics in Java - Examples
Java Generics Tutorial
Generics in Java is one of the important features added in Java 5 along with Enum, autoboxing, and varargs, to provide compile-time type-safety. Generics are also considered to be one of the tough concepts to understand in Java and somewhat it’s true as well. I have read many articles on generics in Java, some of them are quite good and detailed but I still felt that those are either too technical or exhaustively detailed, so I thought to write a simple yet informative article on Java generics to give a head start to beginners without bothering their head too much.
Jumat, 13 November 2020
What is CyclicBarrier Example in Java 5 – Concurrency Tutorial
What is CyclicBarrier in Java
CyclicBarrier in Java is a synchronizer introduced in JDK 5 on java.util.Concurrent package along with other concurrent utility like Counting Semaphore, BlockingQueue, ConcurrentHashMap, etc. CyclicBarrier is similar to CountDownLatch which we have seen in the last article What is CountDownLatch in Java and allows multiple threads to wait for each other (barrier) before proceeding. The difference between CountDownLatch and CyclicBarrier is also a very popular multi-threading interview question in Java. CyclicBarrier is a natural requirement for a concurrent program because it can be used to perform the final part of the task once individual tasks are completed.