nus-cs2113-AY2223S1 / forum

4 stars 0 forks source link

Import statement for importing all classes for a package #14

Closed ngdeqi closed 1 year ago

ngdeqi commented 2 years ago

Can we use a wildcard import statement if we are using all the classes in a particular package?

For example, I am importing ALL the exception classes I have created into my parser class, so it would be better for me to do this: import duke.exception.*; instead of

import duke.exception.exception1;
import duke.exception.exception2;
:
okkhoy commented 2 years ago

You still need to import the classes explicitly. It gives an idea of what all are in play in this particular class (as against using *, where you don't know explicitly what is present)