somethingElse
is a property (data member), not a method. No code in the class is run when you access that member, unlike with a method where code in the class is run.
Here's an example:
public class Foo {
public int bar;
public Foo() {
this.bar = 42;
}
public int getBlarg() {
// code here runs when you call this method
return 67;
}
}
If you create a Foo
object:
Foo f = new Foo();
...you can access the property bar
without parens:
System.out.println(f.bar); // "42"
...and you can call the method getBlarg
using parens:
System.out.println(f.getBlarg()); // "67"
When you call getBlarg
, the code in the getBlarg
method runs. This is fundamentally different from accessing the data member foo
.