Java syntax explanation
public class Best{
public static void main(String[] args) {
System.out.println("Welcome to techy sowmii");
}
}
Starting with Class
public class Best{
- every program must start with a class definition and here we defined the class as Best and file name must and should match with the class name when saving the file, save it using the class name and add ".java" to the end of the filename .
- java is case sensitive MyClass and my class has different meanings. the class has a naming convention and in the class name the first letter starts with an uppercase letter then followed by lowercase
- examples of class are Best, MyClass, JavaCode, etc
- examples of file name are Best.java,MyClass.java,JavaCode.java
Method
- every Java program has a class name that should match the filename, and every program must contain the main() method.
- the code inside this main method gets compiled and then executed by the computer
- Example -public static void main(String[] args) {
System.out.println()
Inside the main() method, we can use the println() method to print a line of text to the screen:
System. out.println("Welcome to techy sowmii");
These println method prints Welcome to techy sowmii to the screen
The curly braces {} marks the beginning and the end of a block of code.
Each code statement must end with a semicolon(;)...........
Related articles
A simple pillow talk between java and java user!!!!!!!!........
write java code in a simple text editor
Java Declare Multiple Variables
No comments:
Post a Comment
Did you find this article helpful?
😁 😀