Java Reference
In-Depth Information
}
In this example, types are used in declarations of the following:
• Imported types (§ 7.5 ) ; here the type Random , imported from the type
java.util.Random of the package java.util , is declared
• Fields, which are the class variables and instance variables of classes (§ 8.3 ),
and constants of interfaces (§ 9.3 ); here the field divisor in the class MiscMath
is declared to be of type int
• Method parameters (§ 8.4.1 ); here the parameter l of the method ratio is de-
clared to be of type long
• Method results (§ 8.4 ); here the result of the method ratio is declared to be of
type float , and the result of the method gausser is declared to be of type double
• Constructor parameters (§ 8.8.1 ) ; here the parameter of the constructor for
MiscMath is declared to be of type int
• Local variables (§ 14.4 , § 14.14 ) ; the local variables r and val of the method
gausser are declared to be of types Random and double[] (array of double )
• Exception parameters (§ 14.20 ) ; here the exception parameter e of the catch
clause is declared to be of type Exception
• Type parameters (§ 4.4 ) ; here the type parameter of MiscMath is a type vari-
able T with the type Number as its declared bound
• In any declaration that uses a parameterized type; here the type Number is
used as a type argument (§ 4.5.1 ) in the parameterized type Collection<Num-
ber> .
and in expressions of the following kinds:
• Class instance creations (§ 15.9 ) ; here a local variable r of method gausser is
initialized by a class instance creation expression that uses the type Random
• Generic class (§ 8.1.2 ) instance creations (§ 15.9 ); here Number is used as a
type argument in the expression new ArrayList<Number>()
• Array creations (§ 15.10 ) ; here the local variable val of method gausser is ini-
tialized by an array creation expression that creates an array of double with
size 2
• Generic method (§ 8.4.4 ) or constructor (§ 8.8.4 ) invocations (§ 15.12 ) ; here
the method loop calls itself with an explicit type argument S
• Casts (§ 15.16 ); here the return statement of the method ratio uses the float type
in a cast
Search WWH ::




Custom Search