Monday, 26 January 2015

Java Arithmetic Compound Operator

Compound Assignment Operators in Java

          Java gives special operators to combine an arithmetic operator with an assignment and which is known as Compound Assignment Operator. This session describes how it works and its benefits.

Consider the following addition and subtraction statements,

                         a = a + 5;
                         b = b - 5;

These statements can be rewritten as follows with the help of Compound Assignment Operator.

                         a += 5;
                         b -= 5;

Compound Assignment operators are available for all arithmetic and binary operators.


General Form:

                        var = var op expression;

Compound assignment Operator Form:

                         var op= expression;


 General Form  Compound Assignment Operator Form
 a = a - 5;  a -= 5;
 a = a + 5;  a += 5
 a = a % 5;  a %= 5
 a = a / 5  a /= 5
 a = a * 5  a *= 5

Advantages of Compound Assignment Operators

          The Compound Assignment Operators are used by Java Professionals to attain two major benefits.

          1. Compound Assignment Operators are shorthand and saves a few letters every time when you type Java Code.

          2. It is efficient than its equivalent long form in some cases.

Compound Assignment Operators Example Program.

Friday, 5 December 2014

Top 10 Interesting Facts About Java

This article refers to few basic facts about Java which show the Purposefulness of Java

  1. 9 out of 10 computers in U.S. run Java and 97% of Enterprise Desktop run it.
  2. Java was originally called Oak.
  3. There are a million Java Developers world Wide.
  4. The median salary for a Java developer in the U.S. is $83973.
  5. Nearly nine of every 10 computers in the U.S. run Java, and 97% of enterprise desktops run the language.
  6. The JUnit testing framework is the top Java technology, used by more than four of five developers. Jenkins is second, used by 70% of developers.
  7. Java is ranked #2 in popularity among programming languages, according to The language C is #1.
  8. 1 Billion Java Downloads per Year
  9. 3 Billion devices run Java
  10. 100% of BLU-RAY Disc Players ship with Java

Monday, 24 November 2014

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

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

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

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.

Popular Posts

Follow by Email

Like Us