Java Reference
In-Depth Information
fields.
*/
@Deprecated
String name;
String firstName;
String lastName;
public static void main(String[] args)
{
Employee emp = new Employee();
emp.name = "John Doe";
}
}
ated. Although
Employee
's
main()
method refers to
name
, the compiler will sup-
press a deprecation warning because the deprecation and reference occur in the same
class.
Suppose you refactor this listing by introducing a new
UseEmployee
class and
class structure.
Listing 3-39.
Referencing a deprecated field from within another class declaration
class Employee
{
/**
* Employee's name
* @deprecated new version uses firstName and lastName
fields.
*/
@Deprecated
String name;
String firstName;
String lastName;
}
class UseEmployee
{