Comments in Java

Just as in the case of C++ and C, Java supports two types of comments namely, single line comments and multi-line comments. The syntax for these types of comments are as follows: Single line comment: //<comment> Multiple line comment: /*<comment>*/ All characters that exist in the comments region are simply ignored by the Java compiler. … Read more

Java Arrays

Arrays are contiguous memory locations that store different variables of the same sort. On the other hand, an array itself is an article on the memory. An array is a container object that holds a fixed number of values of a single type. The length of an array is established when the array is created. After creation, its length is fixed.

Java Is Object-Oriented

To some, object-oriented programming (OOP) technique is merely a way of organizing programs, and it can be accomplished using any language. Working with a real object-oriented language and programming environment, however, enables you to take full advantage of object- oriented methodology and its capabilities of creating flexible, modular programs and reusing code. Many of Java’s … Read more

A Closer Look at the First Sample Program

Although Example.java is quite short, it includes several key features that are common to  all Java programs. Let’s closely examine each part of the program. The program begins with the following lines: /* This is a simple Java program. Call this file “Example.java”. */ This is a comment. Like most other programming languages, Java lets … Read more

Compiling the Program

To compile the Example program, execute the compiler, javac, specifying the name of the source file on the command line, as shown here: C:\>javac Example.java The javac compiler creates a file called Example.class that contains the bytecode version of the program. As discussed earlier, the Java bytecode is the intermediate representation of your program that … Read more