Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is there anything in java like header files in C/C++

Tags:

java

In C, there is this concept of header files that lets you include the header files required for most of the program in one go and so you can only import that one header file in each of your program. I find this pretty neat. Now, I have been working in JAVA for a while and afaik I cannot group together a set of imports that I require for almost every file and put them in one. Am I wrong? And is this better than putting all the required bunch in one java file.

like image 939
I J Avatar asked Oct 24 '11 19:10

I J


2 Answers

There's no such thing. If you require a class from another package (that isn't in java.lang), you'll have to import. But that's practically trivial when using a proper IDE. In Eclipse or NetBeans, you're usually one key combo away from fixing your imports.

like image 102
G_H Avatar answered Sep 19 '22 13:09

G_H


There's no equivalent to header files in java, however you can import whole packages:

import mypackage.*
like image 33
Luchian Grigore Avatar answered Sep 22 '22 13:09

Luchian Grigore