Skip to content

Tag: java

PNGj: Row writing order

The purpose is to draw a small image inside another image at some specified area. Is there any possibility to change only specified rows and avoid rewriting of entire lines of the origin image? I …

Best way to store locators

I’m following page object design pattern for Selenium automation and I can guess that many people store locators in .properties file and access them in code. It seems great to keep locators at separate place. Since, I haven’t work on any big project for Selenium automation, I would like to know th…

Mapping one DB column to two seperate fields using JPA

I’m developing a code generator that have to generate JPA entities from database meta-model files. These model are from home-brewed modeling system which are being used to generate models other than JPA entities. In these models some fields are mapping back to same database column. But it seems like JPA…

Replacing if else statement with pattern

I have a if else statement which might grow in the near future. Since, this is already looking messy, I think it would be better if I can apply any design patterns here. I looked into Strategy pattern but I am not sure if that will reduce if else condition here. Any suggestions? Answer This is a classic Repla…

future.cancel does not work

I have a nice and compact code, which does not work as I expected. The output is : Timeout true END Question: Why does not terminate the future.cancel(true) method the called Runnable? After the program wrote the “END” to the output, the “r” Runnable is still running. Answer The proble…

Comparing multiple integers in IF statement, Java

I am brand new to coding. I’m currently using “Java:How to program” by Deitel, and one of the early exercises has me stumped. It is asking me to use simple, chapter 1 if statements to compare 5 integers (input by the user) and display both the largest and the smallest. I am limited to the la…