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.
|x = TryCast(y, z)||x = (z)((y instanceof z) ? y : null);|
Use VB to Java Converter to convert from VB to Java.
VB.NET and Java Equivalents
Copyright © 1997 – 2018 Tangible Software Solutions, Inc.