# How to define a property of a generic type with a upper bound limit?

**URL:** https://discuss.kotlinlang.org/t/how-to-define-a-property-of-a-generic-type-with-a-upper-bound-limit/11646
**Category:** Support
**Created:** [February 19, 2019, 10:14am UTC](https://discuss.kotlinlang.org/t/how-to-define-a-property-of-a-generic-type-with-a-upper-bound-limit/11646 "2019-02-19T10:14:32Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![firaswu](https://avatars.discourse-cdn.com/v4/letter/f/ecd19e/32.png) [@firaswu](https://discuss.kotlinlang.org/u/firaswu)
#### Post date: [February 19, 2019, 10:14am UTC](https://discuss.kotlinlang.org/t/how-to-define-a-property-of-a-generic-type-with-a-upper-bound-limit/11646/1 "2019-02-19T10:14:32Z")

</div>

What is the Kotlin equivalent of the following Java code?

```
class Test {
    Class<? extends Number> types = new Class[] {
            Integer.class, Long.class, Short.class, Byte.class, Float.class, Double.class
    };
}

```

---

<div class="post-metadata">

### Author: ![tieskedh](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/tieskedh/32/2816_2.png) [@tieskedh](https://discuss.kotlinlang.org/u/tieskedh)
#### Post date: [February 19, 2019, 5:54pm UTC](https://discuss.kotlinlang.org/t/how-to-define-a-property-of-a-generic-type-with-a-upper-bound-limit/11646/2 "2019-02-19T17:54:27Z")

</div>

```
class Test {
    val types = arrayOf<KClass<out Number>>(
        Integer::class, Long::class, Short::class, Byte::class, Float::class, Double::class
    )
}

```

or if you need the java class:

```
class Test {
    val types = arrayOf<Class<out Number>>(
        Integer::class.java, Long::class.java, Short::class.java, Byte::class.java, Float::class.java, Double::class.java
    )
}

```

for more info: [https://kotlinlang.org/docs/reference/generics.html#variance](https://kotlinlang.org/docs/reference/generics.html#variance) or [https://www.baeldung.com/kotlin-generics](https://www.baeldung.com/kotlin-generics)
