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

Java Equivalent to the VB 'Using' Statement

The VB 'Using' statement is a shortcut for a Try/Finally block which disposes an object of type System.IDisposable. Java 7 introduces the 'try with resources' statement, which operates on objects of type java.io.Closeable:

VB:

Using f As New Foo()
End Using

Java 7 or higher:

try (Foo f = new Foo())
{
}

pre-Java 7:

Foo f = new Foo();
try
{
}
finally
{
    f.close();
}


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.