Is there a Java equivalent or methodology for the typedef keyword in C++?


Question

Coming from a C and C++ background, I found judicious use of typedef to be incredibly helpful. Do you know of a way to achieve similar functionality in Java, whether that be a Java mechanism, pattern, or some other effective way you have used?

1
234
11/9/2012 2:40:54 AM

Accepted Answer

Java has primitive types, objects and arrays and that's it. No typedefs.

107
7/28/2009 4:26:37 PM

If this is what you mean, you can simply extend the class you would like to typedef, e.g.:

public class MyMap extends HashMap<String, String> {}

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon