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

Javabasic 2

The document summarizes the structure of a Java program including: 1) package declaration which is optional, 2) import statements which are also optional, 3) mandatory class creation where a class is a user-defined data type, and 4) a mandatory main() method which is the starting point of compilation and accepts command line arguments as a String array. It also covers Java naming conventions and provides an example of a basic Hello World program.

Uploaded by

Jasvan Sundar
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Javabasic 2

The document summarizes the structure of a Java program including: 1) package declaration which is optional, 2) import statements which are also optional, 3) mandatory class creation where a class is a user-defined data type, and 4) a mandatory main() method which is the starting point of compilation and accepts command line arguments as a String array. It also covers Java naming conventions and provides an example of a basic Hello World program.

Uploaded by

Jasvan Sundar
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

structure of java program:

1)package declartion
package: A collection of classes,interfaces,methods to save single name
"package"
1)built-in
these are defined by sun micro systems.started with "java"
ex:
java.lang,java.util,java.io,java.sql,java.awt,java.spring...32
2)user defined
these packages are defined by user or programer.
ex: package anudip;
note:this step is optional.

2)import statement:
it is used to import specified classes or method or interfaces.
ex:
import java.lang;
import java.util;
import java.io;
import anudip;
...
this step is optional.
note:By default one package "java.lang"

3)class creation
it is user defined datatype.
it is a collcetion of data members and methods.
An instance of class is called as "object"
ex:
Emps e1;//Emps is class,e1 is object
this step is mandatory.
4)main() method
syntax:
public static void main(String[] args)
{
st-1;
}
public:it is one of the access modiier.
any where user can access the main method
static:without object user can access main()
void:no return type.Every main() should be not return.
main():Compilation begining point
String[]: String array or group of strings
args:it is used to pass inputs at command prompt.
first args is 0,1....
This step is mandatory.

example:
class Emps
{
public static void main(String[] args)
{
System.out.println("welcome to java");
}
}
java naming notations:
1)Every java keyword should be lower case.
2)Every java class name starts with uppercase and remaining letters lower
case[camel case]
3)Every java method names must be lower case.
If the method consists 2 words first word lower case.Second word first letter
captial.
[readLine()]
4)Every java interface name starts with upper case.
5)Every java Constants must be upper case.
6)Every java variable name mixed case.
7)Every java package name should be lower case.

editor:
1)notepad
2)notepad++
3)editplus
4)vs

IDE:
1)eclipse
2)netbeans
3)javabeans

JDK [JAVA DEVELOP KIT]


[JVM+JRE]
|
oracle java
|
www.oracle.com
|
downloads =>jdk 18 on windows 10/linux 32 or 64 bit
|
path settings:
1)local path=> cmd=> set path=c:\program files\java\jdk 1.8\bin;
2)global path=>my computer=>right click=>properties=>advanced system=>
envinronment variable=> path variable=>edit=>new =>c:\program files\java\jdk
1.8\bin=>ok=>ok
|
command=> c:\> javac
c:\>java -version

//first java program java.lang


class Demo1
{
public static void main(String[] args)
{
System.out.println("welcome to java");
}
}
file =>save=>Demo1.java=>cmd=>
d:\batch10am>javac Demo1.java
java Demo1
|
o/p:welcome to java

You might also like