Java source file structure:
====================
1. A java program can contain any number of classes.
2. Compulsory one class should be declared as public
3. If there is a public class then name of the program and name of the public class must be matched or same,otherwise we will get compile time error.
4. The class which you declared as public,write main() method in that class.
SampleDemo.java:
------------------
class First
{
;;;
;;;
;;;
}
class Second
{
;;;;;
;;;;;
;;;;;
}
public class SampleDemo
{
;;;;;
;;;;;
;;;;;
}
Naming conventions:
================
1.Every class should start with capital letter and if it is having multiple words,every word start with capital letter.
ex:
class Sample
{
;;;
}
class SampleDemo
{
;;;
}
2.Every variable name should start with small letter and if it is having multiple words first word start with small letter,next words start with capital letter.
ex:
int number=10;
int firstNumber=30;
3.Every method name should start with small letter.
public void display()
{
;;;;
;;;;
}
====================
1. A java program can contain any number of classes.
2. Compulsory one class should be declared as public
3. If there is a public class then name of the program and name of the public class must be matched or same,otherwise we will get compile time error.
4. The class which you declared as public,write main() method in that class.
SampleDemo.java:
------------------
class First
{
;;;
;;;
;;;
}
class Second
{
;;;;;
;;;;;
;;;;;
}
public class SampleDemo
{
;;;;;
;;;;;
;;;;;
}
Naming conventions:
================
1.Every class should start with capital letter and if it is having multiple words,every word start with capital letter.
ex:
class Sample
{
;;;
}
class SampleDemo
{
;;;
}
2.Every variable name should start with small letter and if it is having multiple words first word start with small letter,next words start with capital letter.
ex:
int number=10;
int firstNumber=30;
3.Every method name should start with small letter.
public void display()
{
;;;;
;;;;
}
No comments:
Post a Comment