Monday, 24 November 2014

Char Data Type in Java

Unicode Character Representation In Java

A brief note about the way char Data Type used in Java Language.

                        Java uses Unicode to represent characters. Unicode provides a unique number for every character. char is a 16 bit data type and it ranges from 0 to 65536. Unicode standardization makes portability easier regardless of platform, program, and language.
                    Unicode Character Set includes the characters from most of the known languages such as Latin, Greek, Arabic, Indonesia, Hindi, Sanskrit, French, German, Finnish, Irish, Italian, Malay, Chinese, Korean, Hebrew, Japanese etc..

                    Popular Leader in the Industry such as Apple, HP, IBM, Microsoft, SAP, Sybase, Unisys and many more adopted Unicode Standard.

A program which shows all Characters in Unicode Standard

// A simple Java Program to print all Unicode Characters

public class CharactersInJava {  

    public static void main(String[] args) {

        char ch1=0;
        //16 bit Unicode ranges from 0-65536
        for (int i = 0; i < 65536; i++) {          

            if ( (i % 100) == 0)


Sunday, 5 October 2014

JAVA Program to Dispay Current Time in AM PM Method

Time Display USING JAVA

A program to show the current time using SimpleDateFormat Method.

//A small java program to print the time on the screen
import java.util.Date;
import java.text.SimpleDateFormat;

public class DateFormat {
    public static void main(String[] args) {

            Date date = new Date();
            String strDateFormat = "HH:mm:ss a";
            SimpleDateFormat sdf = new SimpleDateFormat(strDateFormat);


00:15:13 AM

Saturday, 4 October 2014

Java Code to Find the Perimeter

Perimeter of a Circle Using Java

A Java program to accept the radius of a Circle from user and calculate the Perimeter.

//A small java program to calculate the Perimeter of a circle


public class CirclePerimeter {

        public static void main(String[] args) {
                int radius = 0;
                System.out.println("Please enter radius of a circle");
                        //get the radius from console
                        BufferedReader br = new BufferedReader(new InputStreamReader(;
                        radius = Integer.parseInt(br.readLine());
                //if invalid value was entered
                catch(NumberFormatException ne)
                        System.out.println("Invalid radius value" + ne);
                catch(IOException ioe)
                        System.out.println("IO Error :" + ioe);
                 * Perimeter of a circle is
                 * 2 * pi * r
                 * where r is a radius of a circle.
                //NOTE : use Math.PI constant to get value of pi
                double perimeter = 2 * Math.PI * radius;
                System.out.println("Perimeter of a circle is " + perimeter);


Please enter radius of a circle
Perimeter of a circle is 75.39822368615503

Friday, 3 October 2014

Java Applet Security

How Java Applet Deals with Security?

Java keeps a "firewall" between a networked application and the computer.

Java Achieves this protection with the help of a Java Compatible Web Browser by confining a Java Program to the Java Execution Environment and not allowing its access to the others parts of the Computer.

Thursday, 2 October 2014

Plantform Independent Java

How Java Achives Platform Independance.

Why  Java is known for Platform Independance.

Quick Note about the Platform Independance (Portability) Feature of Java Language.

          The most important feature of Java is its portability. A program created in one platform has the ability to run on another.


          Eg: When we create a C/C++ program in Windows Operating System, it doesn't have the ability to run in a system which runs on Linux Operating System. 
Platform Dependence of C/C++
The main reason behind this is, C/C++ code takes a few components from its Operating System to run the generated code. So the platform change affects the execution of the program. 


Plantform Independence of Java
Java overcomes the platform independence with the help of Java Virtual Machine (JVM). Java creates a layer between the language and the Operating System. The layer is called Virtual Machine (JVM). There are different Virtual Machines for different Operating Systems as JVM dependent on the Operating System. We need to install the Java Virtual Machine compatible for each Operating System for all devices. Java run on top of this Virtual Machine and make the portability easier. 

        The compilation of Java program makes a class file which contains the bytecode. The bytecode is same for all Operating System and just the JVM deals with it in all Platforms.