mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-10 15:53:46 +00:00
25 lines
404 B
Kotlin
Vendored
25 lines
404 B
Kotlin
Vendored
// FILE: Box.java
|
|
|
|
public class Box<T> {
|
|
private final T value;
|
|
|
|
public Box(T value) {
|
|
this.value = value;
|
|
}
|
|
|
|
public static <T> Box<T> create(T defaultValue) {
|
|
return new Box(defaultValue);
|
|
}
|
|
|
|
public T getValue() {
|
|
return value;
|
|
}
|
|
}
|
|
|
|
// FILE: test.kt
|
|
|
|
fun box(): String {
|
|
val sub = Box<Long>(-1)
|
|
return if (sub.value == -1L) "OK" else "fail"
|
|
}
|