• Saves Valuable Time
  • Trusted Accuracy for 12 Years
  • 15-Day Money-Back Guarantee

Java Equivalent to VB With

With is considered by some to be poor programming practice because it obscures the enclosed code purely for the benefit of reduced typing of one object name during development - you can't see what object you're applying the With operator to from within in the middle of a long With block:

With SomeExtremelyLongNamedPersonObject
    .Name = "Zak"
    .Age = 50
    .Language = Language.English
End With

The closest that you can get in Java is to use a temporary variable with an abbreviated name, but this also obscures your code:

Person p = SomeExtremelyLongNamedPersonObject;
p.Name = "Zak";
p.Age = 50;
p.Language = Language.English;


Use VB to Java Converter to convert from VB to Java.     

Additional resource: VB.NET and Java Equivalents


Copyright © 1997 – 2017 Tangible Software Solutions Inc.