What is a Compilation Unit in Java?

0
32
Spread the love
  • 28
  • 34
  • 56
  • 35
  •  
  •  
  •  
  • 12
  •  
  •  
    165
    Shares

What is a Compilation Unit in Java?

A compilation unit is the highest level syntactic structure that a java virtual machine can recognize and understand. A compilation unit consists of the following components:

Only one of the classes or interfaces present in a compilation unit can be declared public. Compilation units are generally single source code file.

Apart from saving a compilation unit into files, java supports compilation units to be stored in a database. In case, compilation units are stored in a database, the limit of one public class or interface per compilation nit does not hold good. This is only possible as long as there is no way these compilation units are not extracted and placed in an individual file.

Every compilation unit is part of exactly one package. The package is specified by the package directive. If there is no package directive, the compilation unit is a part of the default package.

Don't miss out!
Subscribe To Newsletter

Receive top technical news, lesson ideas, travel tips and more!

Invalid email address
Give it a try. You can unsubscribe at any time.

Spread the love
  • 28
  • 34
  • 56
  • 35
  •  
  •  
  •  
  • 12
  •  
  •  
    165
    Shares

LEAVE A REPLY

Please enter your comment!
Please enter your name here