Wednesday, March 16, 2022

java syntax-1

 

Lets start writing code in java

In Java, every application begins with a class name, and that class name.must match the filename.

lets save the file name as Best.java

this file should print the output welcome to techy sowmii

Best.java (java FILE)

public class Best{

public static void main(String[] args) {

System.out.println("Welcome to techy sowmii");

}

}

Output:Welcome to techy sowmii

you can run the java with the help of simple text editor like notepad and java software must present in the system .

Save the code in Notepad as "Main.java". Open Command Prompt (cmd.exe), navigate to the directory where you saved your file, and type "javac Main.java"

C:\Users\Your Name>javac Main.java

This will compile your code. If there are no errors in the code, the command prompt will take you to the next line. Now, type "java Main" to run the file:

C:\Users\Your Name>java Main

The output should read:

Hello World

RELATED ARTICLES


No comments:

Post a Comment

Did you find this article helpful?
😁 😀

Java identifers

  Identifiers All Java variables must be identified with unique names . For example -different people have different names These unique ...