O'Reilly logo

C# for Java Developers by Adam Freeman, Allen Jones

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required