One important difference between the reference types and primitive types that merits special discussion is the way their values can be used in a method. Let's see the difference by example. First, we create the SomeClass class:
class SomeClass{ private int count; public int getCount() { return count; } public void setCount(int count) { this.count = count; }}
Then we create a class that uses it:
public class ReferenceTypeDemo { public static void main(String[] args) { float f = 1.0f; SomeClass someClass = new SomeClass(); System.out.println("\nBefore demoMethod(): f = " + f + ", count = " + someClass.getCount()); demoMethod(f, someClass); System.out.println("After demoMethod(): f = " + f ...