Identifiers in JAVA


Identifiers are symbols used to name a language entity in different programming languages. You can also say that the identifiers are the name of a computer variables, methods, classes, packages, subroutines, labels, and interfaces.

Certain computer languages don’t allow you to use any or all the characters as Identifiers. For example, the earlier versions of C and C++ only allowed the use of characters such as underscores, digits, and some of the ASCII letters to be used as identifiers. However, the versions of these languages available today along with many other modern-day computer languages allow the use of all Unicode characters in an identifier. These languages still don’t allow the use of white space characters and language operators.

Some of us at times get confused between an identifier and a literal. Unlike literals, identifiers are the way literals are referred to. For example in the famous HelloWorld program, that most of us know, HelloWorld, String, args, main and println are identifiers.

In the Java language, all identifiers must begin with a letter, an underscore (_), the dollar sin ($), or a Unicode currency character. These identifiers don’t allow the use of any other symbol, such as a number and displays error message, if used. Also, Java does not permit the use of a reserved word as an identifier.

All the variables used in a program have specific names. Try assigning mnemonic names to your variables that are closely related to the values they hold. Also, remember that the variables names used in some programming languages such as C are case sensitive. For example, a variable named YourCounter is not the same as the variable named yourcounter. Like many other programming languages, variable names in java can be as long as you want them to be.  Some examples of valid variable names in Java are:

CounterMy,       validvariable,     COUNTER, $counter, _countermy, a, c, _10pen, andjas

The following on the other hand can be an example of a long variable name:

This_is_such_a_long_variable_namethat_goes_on_and_on_to_give_you_an_idea_of_how_long_a_variable_name_can_be.

Continue reading Identifiers in JAVA

JAVA Reserved Word


A reserved word is a special word reserved either by a programming language or by a program. These are called as reserved words because they cannot be used as variable names. For example, in programming languages such as BASIC and COBOL, the IF word is reserved and has a special meaning attached to it.

As you have just seen in the example given above, reserved words have special meanings. The list of these words is defined when a computer language is developed. Not only this, the reserved words are predefined in the specification of the programming language. Programming constructs such as loops, blocks, conditionals, and branches are also identified by using the reserved words.

The programming language’s specification can also include reserved words that could be used in its future versions. For example, ‘const’ and ‘goto’ are reserved words that have no meaning are not used in the current versions of java. However, these words are intended to be used in the future versions only and therefore cannot be defined as identifiers. In such a case, there is no need to break the older Source code of Java. Not only this, a programmer can’t also redefine the reserved words.

Some programmers can use the term reserved word and keyword interchangeably. However, there is a difference between keywords and reserved word. The keyword is special only in certain cases, a reserved word is always a special word that can’t be used in a variable or a constant name defined by a user.

The Java programming language reserves the programming words. You can’t use these words as programmer-defined identifiers also. The reserved words are the words that are already used by the syntax of the Java programming language.

Continue reading JAVA Reserved Word

Java Comments


The computer programs use comments to embed information in its source code. Different programming languages have their own set of rules defined in the program’s specification. Not only this, the syntax for writing comments varies from one programming language to the other. Most of the programming languages ignore comments when their compiler debugs a programming language.

Java uses comments to document the computer program. The comments also act as a reference point for other programmers of things the code contains. The comments in any programming language help programmers in debugging a code. Not only this, they can also be used by a large program for documentation purposes.  Comments help in integrating the source in with source code management systems and other kinds of external programming tools.

On the other hand, a program with awkward comments can even lead to errors in a code that can be difficult to debug. Also, a comment with improper syntax, can lead the debugger using it as a normal programming code.  Many times a lot of unwanted information is also stored as comments.

An example of a comment is given below:

max = 1000;   // This is the default value.

/* check input for valid values and print error message for if problems exist.  */

This program code uses two different types of comments, namely the end-of-line comments and the block comments. An end-of-line comment terminates at the end of the line where it is specified. The block comment on the other hand can continue for several lines or end in one single line depending on its terminator.

Programmers have been using comments for a long time now.  Programs such as BASIC and COBOL use remarks, which are nothing but comments. Similarly, the language ALGOL 60 uses the reserved word comment to start the comment and a semicolon to end or terminate it.

Continue reading Java Comments

The Unicode Character Set


The Unicode is a 16-bit character set. This character set is used in almost all the programming languages. Not only this, it offers a wide variety of characters, some several millions of them, along with the normal ASCII character set. These characters are used to represent the international character set and also contain the characters used in the Asian languages.

The Unicode character sets are not only used in latest programming languages like Java, but also in languages using scientific symbols and even the primitive languages that are no longer used.

In the year 1993, the consortium of companies such as Apple, Microsoft, HP, Digital and IBM created the Unicode character set, using the ISO-10646 standard. Their aim was to produce a single standard. Not only this, this character set is also used in the Windows NT operating system.

All the characters used in the 16-bit Unicode character set occupy the same space. This character set shares its first 256 values with the ISO-Latin character set, which forms the basis of the earlier operating systems such as Windows 3.1 and Windows 95.

In addition to the characters of the ASCII character set, the Unicode character set defines an additional 34,168 distinct coded characters. This character set uses a single instance for each character set. Not only this, Unicode also assigns it a unique name and a code value. Unicode characters also combine with the accent characters defining the base characters that needs to be modified.

Continue reading The Unicode Character Set