Variables
Both Java and C# are strongly typed languages, meaning variables must be declared with a specific type before they are used and can hold only values compatible with that declared type. Both Java and C# define seven types of variables. Despite this coincidence, significant differences exist in how each language categorizes its variable types, as described in Table 5-20.
Table 5-20. A Comparison of Variable Types in Java and C#
Java | C# | Includes |
---|---|---|
class variable | static variable | Fields declared using the static modifier. In Java, this also includes any fields declared in interfaces. Refer to the Members section earlier in this chapter for full details. |
instance variable | instance variable | Fields declared as members of a class (or struct in C#) that are ... |
Get C# for Java Developers now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.