  The intersection ${\bf C}\bigcap {\bf C}^{\perp}$ (${\bf C}\bigcap {\bf
C}^{\perp_h}$) of a linear code ${\bf C}$ and its Euclidean dual ${\bf
C}^{\perp}$ (Hermitian dual ${\bf C}^{\perp_h}$) is called the Euclidean
(Hermitian) hull of this code. It is natural to consider the hull-variation
problem when a linear code ${\bf C}$ is transformed to an equivalent code ${\bf
v} \cdot {\bf C}$. In this paper we introduce the maximal hull dimension as an
invariant of a linear code with respect to the equivalent transformations. Then
some basic properties of the maximal hull dimension are studied. We prove that
for a nonnegative integer $h$ satisfying $0 \leq h \leq n-1$, a linear $[2n,
n]_q$ self-dual code is equivalent to a linear $h$-dimension hull code. On the
opposite direction we prove that a linear LCD code over ${\bf F}_{2^s}$
satisfying $d\geq 2$ and $d^{\perp} \geq 2$ is equivalent to a linear
one-dimension hull code under a weak condition. Several new families of LCD
negacyclic codes and LCD BCH codes over ${\bf F}_3$ are also constructed. Our
method can be applied to the generalized Reed-Solomon codes and the generalized
twisted Reed-Solomon codes to construct arbitrary dimension hull MDS codes.
Some new entanglement-assisted quantum error-correction (EAQEC) codes including
MDS and almost MDS EAQEC codes are constructed. Many EAQEC codes over small
fields are constructed from optimal Hermitian self-dual codes.
