imsavva.com

Folder icon

Coding

Generating PDF with Apache FOP and Maven. An example and some tricks.

This January (and, actually, February) I worked on generating PDF files. During the investigation process, we've chosen Apache FOP as a free powerful tool for this task. Firstly I wanted to write a step by step guide on how to generate a PDF file from a Java object. But eventually, I decided to keep it short, as…
Posted on
2019-02-13

Possible class names in Java

showPostImage(-353751602)

Uncaught exception: the image was stolen by a UFO

What would be the result of execution of the following code? If your answer is "Hello", then you're right! You can use any characters from the Unicode charset, in any case, to name classes (as well as variables and methods), except some preserved words like "null", "volatile", "public", etc. However, it's strongly…
Posted on
2019-01-15

Switch case and default

showPostImage(-1561152684)

Uncaught exception: the image was stolen by a UFO

This snippet will compile and run without issues. It might be dubious whether it's okay to put the "default" block at the first place, but you can place it anywhere. In this case, the result would be: However there is a good practice to put the "default" block at the end of the switch statement. Or avoid using switch…
Posted on
2019-01-13

Variables and fields instantiation

showPostImage(-1205404296)

Uncaught exception: the image is currently being shown in a museum

This code won't compile because of line 4: When we declare a local variable, it must be initialized before use. Class fields don't have to be initialized. In case we didn't specify any value, a default value will be used. The following list represents default field values:
Posted on
2019-01-11

1Z0-808 Preparation notes

The process of studying Java Core. The picture was taken from Unsplash.com. During the preparation time, I was making notes to remember little tricks that I didn't know or forgot. Although I would never recommend using some of the pieces of code from the notes in production, they might be helpful for those who are…
Posted on
2019-01-09

Passed the Oracle 1Z0-808 certification

Good news, everyone! Even though this is the first blog in 2018, I'm still alive and I'm happy to say that I have passed the Oracle Certified Associate exam with 94% of correct answers (I still can't believe it 😱). It took about a month to prepare and I was spending all my free the time after work to read a book and…
Posted on
2018-12-30

Using StringBuilder instead of usual concatenation. When is it appropriate?

showPostImage(1943353928)

Uncaught exception: the image is currently being shown in a museum

You might know that using string concatenation in Java is not a good practice as it might affect performance. In this short article, I will try to describe when it is necessary to use StringBuilder and when we can afford using concatenation (+ sign). Let's start with a simple example: To see how it works under the hood…
Posted on
2017-12-21