Java Virtual Machine (JVM) Architecture

In this tutorial you will learn about Java Virtual Machine (JVM) architecture. What is JVM? Java Virtual Machine (JVM) is software or a virtual machine that takes .class file as an input and runs java bytecode. Java is machine independent but JVM is machine dependent.   What is Bytecode? When java program is compiled using javac compiler, it is converted into intermediate code known as bytecode. The byte code is stored in .class file. Bytecode contains special instructions that are

Read more

Comparable vs Comparator in Java

Here you will learn about Comparable vs Comparator in Java. Difference between Comparable and Comparator is one of the commonly asked questions in Java interviews. Both the interfaces are used to sort collection objects but still there are some differences between them which I have discussed below. Also Read: Comparable and Comparator Example Comparable vs Comparator in Java S.No Comparable Comparator 1. It is used to sort objects on the basis of only one property at a time. For example if

Read more

Linear Search in Java

Here you will learn about linear search in Java. It is one of the simplest and basic searching algorithm which is also known as sequential search. The targeted element is compared with each element of array until it is found. Its best and worst case time complexity is O (1) and O (n) respectively. Also Read: Binary Search in Java Below program shows that how to implement this algorithm in Java. Program for Linear Search in Java

  Output Enter

Read more

Different Ways to Take Input from User in Java

There are mainly five different ways to take input from user in java using keyboard. 1. Command Line Arguments 2. BufferedReader and InputStreamReader Class 3. DataInputStream Class 4. Console Class 5. Scanner Class   Below I have shared example for each of them.     How to Take Input from User in Java Command Line Arguments It is one of the simplest way to read values from user. It will work only when you are running the program from command

Read more

Java Command Line Arguments

Here you will learn about Java command line arguments. The arguments that are passed from command line at the time of running the program are called command line arguments. It is one of the ways to take input from user in java. It works only when we are running the program from command line and not from any IDE.   How to take input from command line in Java? Write the values that you have to input just after the

Read more

Java Properties File – How to Read and Write

In this tutorial you will learn about java properties file and how to perform read and write operations on it.   What is properties file? In Java related technologies, properties file is used to store configuration data or settings of application. It has .properties extension.   Why we need properties file? It makes application maintenance easier. We can change some information in application by doing changes in properties file. We don’t need to recompile the java source files. Let us

Read more

Solve javac is not recognized as an internal or external command Error

The error javac is not recognized as an internal or external command arises when we try to compile any java source file using javac command. The reason for this error is because the path of javac command is not set properly. This error can be solved easily by setting javac compiler path in environment variables. How to solve javac is not recognized as an internal or external command Error? This can be done in two ways as given below.  

Read more

How to Sort ArrayList of Objects in Java

In this tutorial you will learn how to sort arraylist of objects in java. In our previous tutorial we have seen how to sort arraylist of String or Integer type using Collection.sort() method. Can we use that process to sort an arraylist of custom objects? The answer is big no. For doing this we have to use Comparable or Comparator interfaces. Below I have shared an example for each of them. Sort ArrayList of Objects Using Comparable Comparable is used to

Read more
1 7 8 9 10