Ganpati Bappa Alight Motion Editing | A First Simple Program Of Java | Technical Sham


A First Simple Program

           Now that the basic object-oriented underpinning of Java has been discussed, let’s look at some actual Java programs. Let’s start by compiling and running the short sample program shown here. As you will see, this involves a little more work than you might imagine.


 
NOTE : The descriptions that follow use the standard Java SE 6 Development Kit (JDK), which is available from Sun Microsystems. If you are using a different Java development environment, then you may need to follow a different procedure for compiling and executing Java programs. In this case, consult your compiler’s documentation for details.

How To Compile And Run Java 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 contains instructions the Java Virtual Machine will execute. Thus, the output of javac is not code that can be directly executed.

        To actually run the program, you must use the Java application launcher, called java. To do so, pass the class name Example as a command-line argument, as shown here:
C:\>java Example

When the program is run, the following output is displayed:
Hello Java programer's

When Java source code is compiled, each individual class is put into its own output file named after the class and using the '.class' extension. This is why it is a good idea to give your Java source files the same name as the class they contain—the name of the source file will match the name of the '.class' file. When you execute java as just shown, you are actually specifying the name of the class that you want to execute. It will automatically search for a file by that name that has the '.class' extension. If it finds the file, it will execute the code contained in the specified class.


Comments In A Java Languange Programming :

What is comments in java language:

    1. In java The perticular line which you want to write in program this line can't executes the java compiler it also known as Comments.


In Java language Two Types Of Comments Present :

1.Single Line Comments :

// This Is Single Line Comment
This is the First type of comment supported by Java. A single-line comment begins with a // and ends at the end of the line. As a general rule, programmers use multiline comments for longer remarks and single-line comments for brief, line-by-line descriptions. The third type of comment, a documentation comment, will be discussed in the “Comments” section later in this chapter.
2.MultiLine Comments :

/* 
This Is MultiLine Comment
This Is MultiLine Comment
This Is MultiLine Comment
*/
This Is a second type of comment must begin with /* and end with */. Anything
between these two comment symbols is ignored by the compiler. As the name suggests, a
multiline comment may be several lines long.


Perhaps no other concept is more fundamental to a programming language than that of a variable. As you probably know, a variable is a named memory location that may be assigned a value by your program. The value of a variable may be changed during the execution of the program. The next program shows how a variable is declared and how it is assigned a value. The program also illustrates some new aspects of console output. As the comments at the top of the program state, you should call this file Example2.java.



Output :
This is number: 100
The value of number * 2 is 200



So Editing Friends Wait For Complete Our Timer Then You Can Download Our Materials For Free !!!



 
You have to wait 10 seconds.





Post a Comment

Previous Post Next Post