Check out example codes for "update java in ubuntu". It will help you in understanding the concepts better.

Code Example 1

sudo apt-get update
sudo apt-get install oracle-java11-installer-local

Code Example 2

sudo apt install default-jdk

Code Example 3

sudo apt-get install openjdk-8-jdk

Learn ReactJs, React Native from akashmittal.com