Home » Java » Core Java (page 6)

Core Java

The Chameleon Function

In Doctor Who the character Kamelion was a robot which could take any form. The physical prop they used was allegedly very troublesome and only understood by its creator, who wasn’t around to help put it right. So to the Chamelion function … Consider this code: 01 02 03 04 05 06 07 08 09 10 11 12 13 14 ...

Read More »

The Final Word on “final”

In Java, overuse of final feels like SHOUTING. It’s outdated and inappropriate much of the time. Java and JavaScript This is mainly about the final keyword in Java, but my opinion on its counterpart const in JavaScript has changed slightly. That I can think that const is a good thing and final is a bad thing needs some unpacking. I ...

Read More »

JVM with no garbage collection

JVM community keeps on adding new GC and recently new one was added and it is called  Epsilon and is very special one. Epsilon only allocates memory but will not reclaim any memory. It might look like what is use of GC that does not perform any garbage collection. This type of Garbage Collector has special use and we will look ...

Read More »

Need driven software development using Mocks

Excellent  paper on mocking framework by jmock author. This paper was written in 2004 that is 18 years ago but has many tips of building maintainable software system. In this post i will highlight key ideas from this paper but suggest you to read the paper to get big ideas behind mocking and programming practice.  Mock objects are extension of ...

Read More »

Adapter Design Pattern In Java

The Adapter design pattern is a structural design pattern that helps us to connect to the legacy or third-party code that exposes a similar functionality through a different interface. A real-world analogy for an adapter is the one we use to connect our USB cable to an ethernet port. While designing an object-oriented application, we might feel the need for an adapter when say our ...

Read More »

Java: ChronicleMap Part 3, Fast Microservices

Standard Java Maps needs to be initialized upon startup. Learn how to leverage ChronicleMaps that is initializable from a file and reduce microservice startup times significantly and how to share Maps between JVMs. The built-in Map implementations, such as HashMap and ConcurrentHashMap are fast but they must be initialized with mappings before they can be used for looking up values. ...

Read More »

Java: ChronicleMap Part 2, Super RAM Maps

The standard Java Maps, such as the ubiquitous HashMap, are ultimately limited by the available RAM. Read this article and learn how you can create Java Maps with virtually unlimited sizes even exceeding the target machine’s RAM size. The built-in Map implementations, such as HashMap and ConcurrentHashMap work fine as long as they are relatively small. In all cases, they ...

Read More »

Java: ChronicleMap Part 1, Go Off-Heap

Filling up a HashMap with millions of objects will quickly lead to problems such as inefficient memory usage, low performance and garbage collection problems. Learn how to use off-heap CronicleMap that can contain billions of objects with little or no heap impact. The built-in Map implementations, such as HashMap and ConcurrentHashMap are excellent tools when we want to work with ...

Read More »

JEP 358: Helpful NullPointerExceptions

In the post “Better Default NullPointerException Messages Coming to Java?“, I summarized background details related to a draft JEP (at that time) regarding making some types of NullPointerException‘s (NPE’s) messages more useful. It was nice to see last week that this JEP is now a candidate JEP (JEP 358: “Helpful NullPointerExceptions”). In this post, I highlight aspects of JEP 358 ...

Read More »