Complete the example

Report a typo

Imagine we have a multifunctional device with printing, scanning and copying functions. The device should contain a bean of a scanner in it.

Java
@Component
public class Device {
    private Scanner scanner;

    // 1
    public Device(Scanner scanner) {
        this.scanner = scanner;
    }

}
// 2
public class Scanner {
    // a constructor
}
Kotlin
@Component
class Device /* 1 */ constructor(private val scanner: Scanner) {

}
// 2
class Scanner {
    // a constructor
}

Write the annotations divided with a space and start them with @ symbol.

Enter a short text
___

Create a free account to access the full topic