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

Java Equivalent to VB Casts

The closest equivalent to the standard VB casting macros (CType and the corresponding CInt, CStr, etc.) are calls to the 'parse' methods (Integer.parseInt, Short.parseShort, etc.) if the argument is a string, otherwise they are converted to the standard Java casting operator.

The behavior of both the 'parse' methods and the standard Java casting operator are subtly different from the VB casting macros though, so you should always test the behavior of your converted Java code.

The Java equivalent to VB's DirectCast is the standard Java casting operator.

The VB TryCast operator conversion always uses the Java instanceof operator.

VB Java
x = TryCast(y, z) x = (z)((y instanceof z) ? y : null);


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.