0% found this document useful (0 votes)
10 views

Lab Lec 01_Basic Rules

Uploaded by

Sridharan Kannan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Lab Lec 01_Basic Rules

Uploaded by

Sridharan Kannan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Java Basic Syntax

Overview of essential rules and


conventions
Comments in Java
• Single-line Comment: // This is a comment.
• Multi-line Comment:
/*
This is a multi-line comment.
*/
• Documentation Comment:
/** This is a documentation comment. */
Case Sensitivity
• • Java is case-sensitive.
• Example:
• System.out.println("Hello"); (valid)
• system.out.println("Hello"); (invalid)
Class Names
• Start with an uppercase letter.
• Example: class MyJavaProgram (valid), class
myJavaProgram (discouraged)
• Avoid special characters and numbers unless
necessary.
The main() Method
• Entry point of a Java program:
• public static void main(String[] args)
• Variations allowed:
• public static void main(String... args)
Method Names
• Start with lowercase; capitalize inner words.
• Example: employeeRecords() (valid),
EmployeeRecords() (discouraged)
Identifiers in Java
• Valid characters: letters, digits, underscore (_),
currency symbols ($).
• Case-sensitive. Example: MinNumber,
minNumber (different).
• Valid: hello_world, _under_value
• Invalid: 74ak, -amount
White Spaces in Java
• Blank lines and lines with only white spaces or
comments are ignored by the compiler.
Access Modifiers

• Private: Accessible only within the class.


• Default: Accessible within the package.
• Protected: Accessible within the package and
subclasses.
• Public: Accessible everywhere.

(Will discuss later in detail)


Java Keywords
• Keywords or Reserved words are the words in a language that are used
for some internal process or represent some predefined actions. These
words are therefore not allowed to use as variable names or objects.
Reserved words cannot be used as identifiers.
Thank You!
• Questions?

You might also like