Type Synonyms in Java

Type Synonyms in Java

Is there anyway (a workaround) to define type synonyms in Java, similar to the following definition in Scala?

type Row = List[Int];

Though it might not be exactly the same, I was thinking of the following code (I replaced List with ArrayList, since List is an interface in Java):

public class Row extends ArrayList<Integer>{}

Is there any other way to achieve type synonym mechanism in java?

11

1 Answer

Unfortunately not. See Is there a Java equivalent or methodology for the typedef keyword in C++? for an older duplicate of this question, using C++ terminology instead of Scala terminology.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

David Miller
Author

David Miller

David Miller brings 15 years of experience in global economics, personal finance strategy, and market dynamics. He specializes in turning complex economic trends into actionable insights for everyday readers.