Posts

Java Data Types (Primitive)

 Java data types As the name suggests, data types in Java specify the type of data that can be stored in Java variables. Java is a static type language. This means that all variables must be declared before they can be used. int speed;   Here the  speed  is a variable and the data type of the variable is  int . The  int  data type determines that the  speed  variable can only contain integers. There are 8 predefined data types in the Java programming language, called primitive data types. Note: Besides the primitive data types, there are also referenced types (object type). 8 primitive data types 1.boolean type The Boolean data type has two possible values, true or false. Default: false. They are generally used for true / false conditions. Example 1: Java Boolean Data Type class Main { public static void main (String[] args) { boolean flag = true ; System.out.println(flag); // prints true } } 2.byte type The byte ...

Java JDK, JRE and JVM

Image
 What is JVM? JVM (Java Virtual Machine) is an abstract machine that allows your computer to run a Java program. When you run the Java program, the Java compiler first compiles your Java code into bytecode. Then, the JVM translates the bytecode into native machine code (a set of instructions that a computer's processor executes directly). Java is a platform independent language. This is because when you write Java code, it is ultimately written for JVM but not for your physical machine (computer). Because JVM runs Java bytecode which is platform independent, Java is platform independent. Working of Java Program What is JRE? JRE (Java Runtime Environment) is a software package that provides Java class libraries, a Java Virtual Machine (JVM), and other components required to run Java applications. JRE is the superset of JVM. Java Runtime Environment If you need to run Java programs, but not develop them, JRE is what you need. What is JDK? JDK (Java Development Kit) is a software deve...

Java Introduction

Java Hello World Program   A " Hello, World! " is a simple program that produces " Hello, World! " on the screen. Since it is a very simple program, it is often used to introduce a new programming language to a beginner. Let's explore how Java "Hello, World!" program works. If you want to run this program on your computer, make sure that Java is correctly installed. Additionally, you need an IDE (or text editor) to write and edit Java code. For that Java "Hello world!" // Your First Program class HelloWorld { public static void main (String[] args) { System.out.println( "Hello, World!" ); } } The output will be: Hello, World! Comment Java "Hello, World!" Does the program work? // Your First Program In Java, any line starting with // is a comment. Comments are intended for users reading the code to better understand the intent and functionality of the program. It is completely ignored by the Java co...