In this article, how to write First/Sample Program using Java is explained in detail. We can write a simple java program easily after installing the JDK.
It's time to write your first program! The following instructions are for users of Windows vista and Windows XP. To create a simple java program, you need to create a class that contains the main method. Your first application will simply display the greeting "Hello world!".
To create the First/Sample Program using Java, follow the program. (From topic how to write First/Sample Program using Java)
To create the First/Sample Program using Java, follow the program. (From topic how to write First/Sample Program using Java)
Ex:1
//program related to First/Sample Program using Java.
//program related to First/Sample Program using Java.
class sample{
Public static void main(String args[]){
} (From topic how to write First/Sample Program using Java)
}
Save the file with the class keyword (In this case I have used sample as class Keyword) save it as "sample.java"
the command for compiling of code is "javac.sample.java"
the command for execution of code is "java sample"
Output
How to save and Execute the Java programs.
- Open the notepad and write the code/program which you want to execute.
- Save the file name as "filename.java"(Ex. if the class keyword is sample then filename should be the sample).
- For compiling the program, open cmd define the path of saved file (Ex. if it is in C folders give c: and press enter)
- After compiling, byte code is generated for every class in a program for the above program the byte code generated as "sample.class".
- Now run the program using the class name which contains the main method with the command "java filename". (From topic how to write First/Sample Program using Java)
Run process is carried by JVM(Java Virtual Machine).It searches for the main method for execution, "main()" is the starting point of execution of java program,without main method we can't execute the program.
*For practicing copy the code paste it in notepad file save it, compute it and run the file check the results.*
Do check my new startup Surprise Planners in Hyderabad- Lavish Surprises
Continue to next topic Basic Structure and Fundamentals of java.
Begin your career in Digital Marketing,What is digital marketing? Digital Marketing online course. It's an current evolving technology which can give support to establish your own startup through Digital Marketing.
Begin your career in Digital Marketing,What is digital marketing? Digital Marketing online course. It's an current evolving technology which can give support to establish your own startup through Digital Marketing.
Hi Friends, Please comment down your views in the comment section below. Thank you...
No comments:
Post a Comment