# Category Archives: Java Basics

## Factorial of Large Number in Java

It is not possible to store factorial for large number like 50 into inbuilt data types like integer or long. Because factorial of 50 has almost 60 digits. Imagine how we can store it in int or long. We can find factorial of such numbers using BigInteger class defined in java.math package.  Below program shows… Read More »

## Program to Convert Binary to Decimal in Java

Here you will get program to convert binary to decimal in Java. There are mainly two ways to convert a binary number to decimal number in Java. 1. By using parseInt() method of Integer class. 2. By using user defined logic. Program to Convert Binary to Decimal in Java By using Integer.parseInt() Integer.parseInt() method takes… Read More »

## Java Program to Find Current Date and Time

We can find current date and time in Java in two ways. The first way is to use Date class and second way is to use Calendar class. Below I have shared Java program to find current date and time. First I am defining the date and time format using DateFormat and SimpleDateFormat class and… Read More »

## Program for Armstrong Number in Java

Armstrong number is a n digit number such that the sum of digits raised to the power n is equal to the number. For example: 153 is armstrong number because here n=3 and 13+53+33=153. 120 is not armstrong number because 13+23+03!=120. Below I have shared a Java program that checks whether a number is armstrong… Read More »

## Anonymous Class in Java

Anonymous class in Java is a class without name. Its name is decided by the compiler. It enables us to declare and instantiate the class at the same time. It is like local class except that it does not have any name. We can use it only once. Anonymous class is also known as anonymous… Read More »

## Java Escape Sequences With Program Example

A character preceded by a backslash () is known as escape sequence. There are total 8 escape sequences in Java which have special meaning to the compiler. When we use an escape sequence in print statement then the compiler interpret it accordingly. All the escape sequences with program example is given below. Java Escape Sequences… Read More »

## Type Casting in Java

Converting one data type to another data type is known as type casting. Type Casting in Java is of two types i.e. Implicit Type Casting which is also known as Automatic Type Casting and Explicit Type Casting. Implicit or Automatic Type Casting In this, smaller data type is converted to bigger data type which is also… Read More »

## Data Types and Naming Conventions in Java

Data Types in Java Used to represent the type of memory allocation. Used with variables and methods. These are fixed. Primitive Data Types Primitive data types are defined already by the programming language. In Java there are 8 primitive data types. Non-Primitive Data Types Non-Primitive data types are defined by the user. They are Class,… Read More »

## Java Variable Types and Rules for Declaring Variables

Variable is nothing it is just the name of memory location. While declaring variables we must follow rules given below. Rules for Declaring Variables in Java 1. Variable name must bound with data type. It means while declaring a variable we must specify its data type. Ex: int x=10; 2. Reserve word or keywords cannot… Read More »

## JVM: Java Virtual Machine Architecture and Structure

JVM is responsible for taking .class file and converting that .class file in machine code instructions that can be executed by microprocessor. It’s not a machine, it’s a program. JVM verifies the code before execution (Sandbox Security). JVM is platform dependent and it is heart of Java language. There are four phases of JVM Load… Read More »

## What is .class File and Bytecode in Java?

This tutorial will help you to learn about what is .class file and bytecode in java language. You may like to read previous tutorial about How to Write, Compile and Run Your First Java Program? What is .class File and Bytecode When Java source file is compiled by Java compiler it is converted into Java… Read More »

## How to Write, Compile and Run Your First Java Program?

Before running Java programs you need to install and setup java. For installation guide read: Java Installation: Downloading, Installing and Setting Path How to write and run Java programs? Open notepad and write below program.   class demo {                 public static void main(String…S)                 {                                 System.out.println(“Java Programming”);                 } } Now save the file… Read More »