Tag Archives: fields

Initializing fields in Java classes

It is often possible to initialize class fields and instance fields as they are declared. For example, This works well when there is a simple assignment. However, for more complicated assignments we may need to use an initialization block. A … Continue reading

Posted in Uncategorized | Tagged , , | 1 Comment

Using qualified names to access shadowed fields

This example code shows how we can use qualified names to access shadowed fields when programming in Java. Class declaration with shadowed fields:

Posted in Uncategorized | Tagged , , , , | Leave a comment

Passing Java objects by value

Primitive data types (such as int, char, etc.) are passed into methods by value, as demonstrated in the following example. Reference data types (this includes objects) are also passed by value. When a method returns, the passed in object still … Continue reading

Posted in Uncategorized | Tagged , , , , | Leave a comment