Tags / Java
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…
Possible class names in Java
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…
Switch case and default
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…
Variables and fields instantiation
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:
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…
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…
Using StringBuilder instead of usual concatenation. When is it appropriate?
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…