JavaFX example of a MP3 player

This is a simple example of a mp3 player created with JavaFX. It has a button to open and play the track, pause, resume and stop buttons with their respective functionalities. To play the music we use MediaPlayer class -> The MediaPlayer class provides the controls for playing media. MediaPlayer provides the pause(), play(), stop() … Read more

Java FX example of a TO DO list

Simple Java FX application which creates and removes elements from the list. This is a basic example of a To Do List application using JavaFX. The program creates a window with a text field for inputting new tasks, a list view for displaying the tasks, and two buttons for adding and removing tasks. The tasks … Read more

Java FX Example of simulate Earth going around the Sun

In this example we will use Java FX and create animation in which Earth will go around the sun: Maven pom.xml dependencies of JavaFX: Java code: This program creates a simple animation of the Earth going around the Sun using the JavaFX library. The animation is created using a PathTransition object, which animates a node … Read more

Java introduction to BigDecimal

BigDecimal represent immutable, arbitrary-precision signed decimal numbers. A BigDecimal consists of an arbitrary precision integer unscaled value and a 32-bit integer scale. The BigDecimal class provides operations for arithmetic, scale manipulation, rounding, comparison, hashing, and format conversion. The toString() method provides a canonical representation of a BigDecimal. Why we need BigDecimal? We already have double, … Read more

Java equals() and hashCode()

Difference between comparison and equality check In many cases we have to compare objects. There are different type of comparison. In some cases you need to order (sort) some object based on some rules. Then in Java you can use Comparable and Comparator. In other cases we need to check if the object are logically … Read more

Java introduction String

The String class represents character strings in UTF-16 encoding. All string literals in Java programs, such as “abc”, are implemented as instances of this class. Strings are constant; their values cannot be changed after they are created. String buffers ( StringBuffer and StringBuilder ) support mutable strings. Because String objects are immutable they can be … Read more

Java method overriding

In Java method overriding can exist when there is Parent-Child classes and the child class provide specific implementation of a method that is also present in the Parent class. Chair [ Parent class ] | int weight() [ Method of the Chair class ] | | [Armchair extends Chair] \/ Armchair [ Child class ] … Read more