What is the java equivalent of VBA's "With" statement

In VB / VBA you can do something like this:

With person
    .Name = "John"
    .Age = 32
End With

But in java I can't figure out how or if that functionality exists. Everything I see seems to just repeat the object references, like this:

person.setName("John");
person.setAge("32");

If it doesn't exists, is there at least some methodology to cut down on the repetition?

Jon Skeet
people
quotationmark

If it doesn't exists, is there at least some methodology to cut down on the repetition?

Nope, not really - not unless you control the type.

If you do control the type, you can make the set methods return this, allowing you to chain the method calls. This is often useful for builder types:

Person person = Person.newBuilder().setName("John").setAge(32).build();

(You can just make your types mutable rather than separating builder types from immutable non-builder types, but I'm just a fan of immutability...)

people

See more on this question at Stackoverflow