```java public __ByValue class Example { } ```

public __ByValue class Example { }
public __ByValue class Example { }
8 Replies
ThomasMiz
ThomasMiz5y ago
No thanks Already had enough cringe trying to instantiate an array of a generic type for my generic array list class
queenvicky
queenvickyOP5y ago
__ByValue makes a class a value type Read here: https://jaxenter.com/java-value-type-163446.html
Peter Verhas
JAXenter
The new ValueType in Java: Why value types are important
Java, as it is now, has two different types of data—primitives and objects. In the coming releases, there will be a new type that is called ValueType.
queenvicky
queenvickyOP5y ago
If Java is better at one thing, that is generics.
ThomasMiz
ThomasMiz5y ago
Fuck new T[size], all my homies use (T[])new Object[size] and ignore the warning I mean what the fuck Why?
queenvicky
queenvickyOP5y ago
you know the ClassA<? super T> that is not possible in C# you can't imply a base class with generics in C# and that can be very usefull for example (from JavaFX):
public class EventHandler<T> {
public EventType(final EventType<? super T> superType, final String name) {
// Implementation
}
}
public class EventHandler<T> {
public EventType(final EventType<? super T> superType, final String name) {
// Implementation
}
}
Also: In Java you can have instances of generic classes without specifing a generic type
ThomasMiz
ThomasMiz5y ago
I still dont get why you'd wanna do that Pretty sure that's just because they wanted to give legacy support to pre-generics code You still can't use primitive types (or nonexistant structs) as generics
queenvicky
queenvickyOP5y ago
Not only instances - you can also declare variables without a generic parameter and then decide what generic parameter to use when instancing. Very usefull for class variables.
ThomasMiz
ThomasMiz5y ago
And using the Integer/Double/etc classes seems wasteful

Did you find this page helpful?