Javabasic 2
Javabasic 2
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