Declaration of Java file
·
Starting with our source file of java in which
we are writing our java code.
·
Java source file saved with .java extension.
·
Some rules while declaring the source file as
follows,
ü
A source file can have only one public class.
ü
Source file can have any number of non-public
classes
ü
If the source file contains public class then
file name must match with public class name.
ü
If the source file does not contain public class
then there is no naming restrictions to file name.
Example
|
1) X.java
public Class X
{
===========
}
|
3) Y.java
public Class Y
{
============
}
|
|
2) Z.java
Class
A
{
========
}
Class
B
{
========
}
|
4) R.java
Class Z
{
============
}
Class Y
{
=============
}
|
NOTE: For every source file of java .class file will be generated.

0 comments: