0% found this document useful (0 votes)
5 views12 pages

Java Structure: Packages and Main Method

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)
5 views12 pages

Java Structure: Packages and Main Method

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

Structure of Java

package packagename;

import packagename;

class classname{

variables;

methods/constructors;

main method(){

// executing code .

}
package statement
• In real time we create packages for better code segregation.
• package statement is completely optional(Mandatory for real time
projects).
• If we are writing a package it should be the first line.
• Maximum one package statement can write.
Import statement
• To import existing and user defined packages.
• Importing is also completely optional.
• If we are writing an import statement after package and before class
declaration.
• We can write any number of imports.
Java
Class ??
Main method in Java
• Can write any number of statements.
• But each statement should be terminated with ;
(semicolon) j
• java is case sensitive.
• If no main method, code compiles but run time error
occurs.
• we can overload main method(Will be discussed in
OOPS).
Code Comments
Single line comment - //

Multi line Comment


public void connectToDB() {
/*
* BusinessLogic bl = new BusinessLogic();
[Link](); Logics lg=new
* Logics();
*/
}

You might also like