Articles


Why String Is Immutable?

This is one of the most popular interview questions. In this blog, we are going to talk about it and help you find the answer. String is one of the most used classes in any application. For storing the username, password, address, IP address, etc., we need to create String objects. So, it is necessary to understand why our most famous and used class is immutable.

Source de l’article sur DZONE

We are very much committed to improving accessibility across our products, and I’m happy to announce that with the upcoming release of IntelliJ IDEA 2018.3 — we’ve made some notable improvements.

High Contrast Theme

We’ve added support for a new High Contrast Theme, which can be accessed using the drop-down list from the theme options under Preferences (Settings) | Appearance & Behaviour or via the Ctrl-` shortcut on macOS, Windows, and Linux.

Source de l’article sur DZONE

In this article, we will be talking about Server Push Technology that is actually part of the HTTP/2 spec.

The most important feature of Servlet 4.0, due to HTTP/2, is the implementation of the server push capability. The concept behind this technique is that if the client/browser requests a certain resource, the server assumes, in advance, that some other related resources may also be requested soon. Because of this assumption, it pushes them into the cache (called ‘cache push’) before they are actually needed. For example, it is very much likely that when a webpage is loaded, it may eventually request a CSS file or another image. The server proactively starts pushing the bytes of these assets simultaneously, without the need for the client to make an explicit request.

Source de l’article sur DZONE

In Java, boxed numbers are instances of classes, such as java.lang.Integer  or  java.lang.Double , that wrap or "box" the respective primitive types: int,  double, etc. They were designed to allow Java apps to pass around numbers as objects and, more importantly, to store numbers in the common collections, such as java.util.ArrayList,  java.util.HashMap, etc. The need to store numbers in lists and maps is very common. To satisfy it, the JDK developers had two choices:

  • Provide specialized collections, i.e. lists and maps, for every primitive type and their combinations. For example, this could include IntArrayListObjectToDoubleHashMap,  IntToObjectLinkedHashMap,  IntToLongConcurrentHashMap, etc.

    Source de l’article sur DZONE


As promised, the just-released Java, JavaFX theme in JMetro version 4.6 brings a new style for the Progress Bar.

The Progress Bar has two possible states: determinate and indeterminate, and the new JMetro version has different styles for these two. In this post, I’ll go into greater detail about some API design principles I abide by in JMetro.

Source de l’article sur DZONE


How To Make Your Scala Applications Compile Faster

With Scala, JVM developers get a host of benefits over other programming languages. From code conciseness (fewer LOC) and native scalability to support for functional programming paradigms and type safety, Scala is the language of choice for modern enterprises like Amazon, HPE, PayPal, and Walmart.

Source de l’article sur DZONE

When writing unit tests, it is common to initialize method input parameters and expected results in the test method itself. In some cases, using a small set of inputs is enough; however, there are cases in which we need to use a large set of values to verify all of the functionality in our code. Parameterized tests are a good way to define and run multiple test cases, where the only difference between them is the data. They can validate code behavior for a variety of values, including border cases. Parameterizing tests can increase code coverage and provide confidence that the code is working as expected.

There are a number of good parameterization frameworks for Java. In this article, we will look at three different frameworks commonly used with JUnit tests, with a comparison between them and examples of how the tests are structured for each. Finally, we will explore how to simplify and expedite the creation of parameterized tests.

Source de l’article sur DZONE

Gradle Kotlin DSL 1.0 release candidate is generally available, including Gradle 4.10. The Kotlin DSL is nearly ready for widespread use.

We want you to enjoy a build authoring experience with the benefits provided by Kotlin’s static type system: context-aware refactoring, smart content assist, debuggable build scripts, and quick access to documentation. In case you haven’t seen it, you can watch Rodrigo B. de Oliveira demonstrate these benefits in this KotlinConf 2017 video.

Source de l’article sur DZONE

Here I am with another useful design pattern for you — the adapter design pattern. I will also highlight the differences between the decorator design pattern (see my previous article, Decorator Design Pattern in Java, here) and the adapter design pattern.

Adapter Design Pattern

  • The adapter design pattern is a structural design pattern that allows two unrelated/uncommon interfaces to work together. In other words, the adapter pattern makes two incompatible interfaces compatible without changing their existing code.
  • Interfaces may be incompatible, but the inner functionality should match the requirement.
  • The adapter pattern is often used to make existing classes work with others without modifying their source code.
  • Adapter patterns use a single class (the adapter class) to join functionalities of independent or incompatible interfaces/classes.
  • The adapter pattern also is known as the wrapper, an alternative naming shared with the decorator design pattern.
  • This pattern converts the (incompatible) interface of a class (the adaptee) into another interface (the target) that clients require.
  • The adapter pattern also lets classes work together, which, otherwise, couldn’t have worked, because of the incompatible interfaces.
  • For example, let’s take a look at a person traveling in different countries with their laptop and mobile devices. We have a different electric socket, volt, and frequency measured in different countries and that makes the use of any appliance of one country to be freely used in a different country. In the United Kingdom, we use Type G socket with 230 volts and 50 Hz frequency. In the United States, we use Type A and Type B sockets with 120 volts and 60 Hz frequency. In India, we use Type C, Type D. and Type M sockets with 230 volts and 50 Hz. lastly, in Japan, we use Type A and Type B sockets with 110 volts and 50 Hz frequency. This makes the appliances we carry incompatible with the electric specifications we have at different places.
  • This makes the adapter tool essential because it can make/convert incompatible code into compatible code. Please notice here that we have not achieved anything additional here — there is no additional functionality, only compatibility.

To better understand this, let’s look at an example of geometric shapes. I am keeping the example relatively simple to keep the focus on the pattern. Suppose we have a project of drawing, in which we are required to develop different kinds of geometric shapes that will be used in the Drawing via a common interface called  Shape.

Source de l’article sur DZONE

In continuation of my previous articles on design patterns, here I am with another very useful pattern — the bridge design pattern.

Bridge Design Pattern

  • The bridge design pattern is a structural pattern used to decouple an abstraction from its implementation so that the two can vary independently.

    Source de l’article sur DZONE