6.5.5
Meaning of Expression Names
NAMES
Otherwise, the identifier appears within an interface declaration ( 9):
N
If there is not exactly one member of that interface ( 9.2) that is a field with
that name, then a compile time error results.
N
Otherwise, the expression name denotes the value of the single member
field of that name. The type of the expression name is the declared type of
the field. If the
Identifier
 appears in a context that requires a variable and not
a value, then a compile time error occurs.
In the example:
class Test {
static int v;
static final int f = 3;
public static void main(String[] args) {
int i;
i = 1;
v = 2;
f = 33;
//
compile time error
System.out.println(i + " " + v + " " + f);
}
}
the names used as the left hand sides in the assignments to
i
,
v
, and
f
 denote the
local variable
i
, the field
v
, and the value of
f
 (not the variable
f
, because
f
 is a
final
 variable). The example therefore produces an error at compile time
because the last assignment does not have a variable as its left hand side. If the
erroneous assignment is removed, the modified code can be compiled and it will
produce the output:
1 2 3
6.5.5.2
Qualified Expression Names
If an expression name is of the form
Q.Id
, then
Q
 has already been classified as a
package name, a type name, or an expression name:
If
Q
 is a package name, then a compile time error occurs.
If
Q
 is a type name that names a class type ( 8), then:
N
If there is not exactly one accessible ( 6.6) member of the class type that is
a field named
Id
, then a compile time error occurs.
N
Otherwise, if the single accessible member field is not a class variable (that
is, it is not declared
static
), then a compile time error occurs.
96






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

java hosting

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Inexpensive Web Hosting  Jsp Web Hosting

Cheapest Web Hosting Jsp Hosting Cheap Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved