Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
Rollback to Revision 1
Source Link
C. K. Young
  • 224.2k
  • 47
  • 394
  • 446

.NET has reified generics; Java has erased generics.

The difference is this: if you have an List<String>ArrayList<String> object, in .NET, you can tell (at runtime) that the object has type List<String>ArrayList<String>, whereas in Java, at runtime, the object is of type ArrayList; the String part is lost. If you put in non-String objects into the ArrayList, the system can't enforce that, and you'll only know about it after you try to extract the item out, and the cast fails.

.NET has reified generics; Java has erased generics.

The difference is this: if you have an List<String> object, in .NET, you can tell (at runtime) that the object has type List<String>, whereas in Java, at runtime, the object is of type ArrayList; the String part is lost. If you put in non-String objects into the ArrayList, the system can't enforce that, and you'll only know about it after you try to extract the item out, and the cast fails.

.NET has reified generics; Java has erased generics.

The difference is this: if you have an ArrayList<String> object, in .NET, you can tell (at runtime) that the object has type ArrayList<String>, whereas in Java, at runtime, the object is of type ArrayList; the String part is lost. If you put in non-String objects into the ArrayList, the system can't enforce that, and you'll only know about it after you try to extract the item out, and the cast fails.

changed ArrayList<string> to List<string>
Source Link
Judah Gabriel Himango
  • 60.2k
  • 39
  • 162
  • 218

.NET has reified generics; Java has erased generics.

The difference is this: if you have an ArrayList<String>List<String> object, in .NET, you can tell (at runtime) that the object has type ArrayList<String>List<String>, whereas in Java, at runtime, the object is of type ArrayList; the String part is lost. If you put in non-String objects into the ArrayList, the system can't enforce that, and you'll only know about it after you try to extract the item out, and the cast fails.

.NET has reified generics; Java has erased generics.

The difference is this: if you have an ArrayList<String> object, in .NET, you can tell (at runtime) that the object has type ArrayList<String>, whereas in Java, at runtime, the object is of type ArrayList; the String part is lost. If you put in non-String objects into the ArrayList, the system can't enforce that, and you'll only know about it after you try to extract the item out, and the cast fails.

.NET has reified generics; Java has erased generics.

The difference is this: if you have an List<String> object, in .NET, you can tell (at runtime) that the object has type List<String>, whereas in Java, at runtime, the object is of type ArrayList; the String part is lost. If you put in non-String objects into the ArrayList, the system can't enforce that, and you'll only know about it after you try to extract the item out, and the cast fails.

Source Link
C. K. Young
  • 224.2k
  • 47
  • 394
  • 446

.NET has reified generics; Java has erased generics.

The difference is this: if you have an ArrayList<String> object, in .NET, you can tell (at runtime) that the object has type ArrayList<String>, whereas in Java, at runtime, the object is of type ArrayList; the String part is lost. If you put in non-String objects into the ArrayList, the system can't enforce that, and you'll only know about it after you try to extract the item out, and the cast fails.