Posts

JDK, JVM and JRE in Java

Image
  Java is a powerful, versatile programming language used to build a wide range of applications, from mobile apps to large-scale enterprise systems. A key part of working with Java effectively is understanding its core components: the JDK (Java Development Kit), the JVM (Java Virtual Machine), and the JRE (Java Runtime Environment). Java Virtual Machine(JVM):- The JVM is a virtual machine that enables a computer to run Java programs. It converts Java bytecode, produced by the Java compiler, into machine code that the host operating system can execute. The JVM's ability to run bytecode on any platform that has a compatible JVM implementation makes Java a "write once, run anywhere" language. JVM Architecture:- Class Loader Role : The class loader is responsible for dynamically loading Java classes into the JVM. It loads classes from the filesystem, network, or other sources as needed. Types : Bootstrap Class Loader : Loads core Java libraries located in the <JAVA_HOME...

Stack and Queue in java

Image
  Stack:-      Stack is a Java class that extends Vector in the Collection framework. In stack data structure have FILO (First In Last Out), LIFO (Last In First Out) concept.     Its mean, if we add some data   to the stack, inserted first data  we can execute it in last. We can execute last inserted data at first.      Java provides an implementation of a stack through the java.util.Stack class, which extends the Vector class.     If there are any element is not in the stack, we called that stacks as empty stack.       In a stack, you typically have operations like:                Push :-     Adds an element to the top of the stack.                Pop :-Removes and returns the top element from the stack.                Peek : - Returns the top elem...