+92 332 4229 857 99ProjectIdeas@Gmail.com

Write A Basic Java Program

How to write a basic java program:


Write a Basic Java Program….!!!!
/* The HelloWorld class implements an application that simply displays "Hello World" on the console.Write following code in notepad */
 public class HelloWorld  {

        public static void main(String[] args) {

    System.out.println("Hello World!");

Compiling and Running the program….!!!!

Save this file with a same name of your class in some directory and compile it using (before doing this, see Software Requirements section)
       javac HelloWorld.java (in command prompt)

If the above executed successfully and gives no error it means your code is free of error, now go there where you save this file you would see a
       HelloWorld.class file this is a file which contains a bytecode which you can run on any operating system.

Run the compiled file by using the command:
       java HelloWorld (in command prompt)

After writing above command you see a Hello World! Displaying on console.

Naming Conventions of Java....!!!!

     Class Names: First letter of word should be capital if you are defining any class i.e.,   Student , StudentInfo , FileHandling etc…..

     Method Names: First letter of any method should be small and the preceding words first letter should be capitalized i.e., print() , printResult() , loadDataFromFile() etc…..

     Variable Names: same strategy as of method names i.e., flag, myVariable , counterOne  etc….