Monday, 26 January 2015

Arithmetic Compound Assignment Operators

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.

Syntax:


General Form:

                        var = var op expression;

Compound assignment Operator Form:

                         var op= expression;

Examples:


 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.


Friday, 5 December 2014

10 Facts About Java

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 Tiobe.com. 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

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
                    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++) {          

            System.out.print(ch1);
            ch1++;
            if ( (i % 100) == 0)

               System.out.println();              
        }      
    }
}

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);
            System.out.println(sdf.format(date));
    }
    
}

Output:


00:15:13 AM