| MATLAB Function Reference | ![]() |
import package_name.*
import class_name
import cls_or_pkg_name1 cls_or_pkg_name2...
import
L = import
import package_name.* adds specified package_name to the current import list. Note that package_name must be followed by .*.
import class_name adds a single class to the current import list. Note that class_name must be fully qualified (that is, it must include the package name).
import cls_or_pkg_name1 cls_or_pkg_name2... adds all named classes and packages to the current import list. Note that each class name must be fully qualified, and each package name must be followed by .*.
import with no input arguments displays the current import list, without adding to it.
L = import with no input arguments returns a cell array of strings containing the current import list, without adding to it.
The import function only affects the import list of the function within which it is used. When invoked at the command prompt, import uses the import list for the MATLAB® command environment. If import is used in a script invoked from a function, it affects the import list of the function. If import is used in a script that is invoked from the command prompt, it affects the import list for the command environment.
The import list of a function is persistent across calls to that function and is only cleared when the function is cleared.
To clear the current import list, use the following command.
clear import
This command may only be invoked at the command prompt. Attempting to use clear import within a function results in an error.
The import function allows your code to refer to an imported class by class name only, rather than with the fully qualified class name. import is particularly useful in streamlining calls to constructors, where most references to Java™ classes occur.
import meta.*
import java.lang.String
s = String('hello'); % Create java.lang.String object
import java.util.* java.awt.* f = Frame; % Create java.awt.Frame object methods Enumeration % List java.util.Enumeration methods
![]() | imformats | importdata | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |