Как в input String метод Scanner записать два слова как переменную? Задача jetbrains academy

    package com.Scanner;
    import java.util.Scanner;
    public class Scaner {
        public static void main(String[] args) {
            Scanner scanner = new Scanner(System.in);
            String name = scanner.nextLine(); //Nick
            int age = scanner.nextInt();// 25
            scanner.nextLine();
            String education = scanner.nextLine(); //secondary
            int experience = scanner.nextInt(); //3
            scanner.nextLine();
            String fusion dishes = scanner.nextLine();// не компилирует
            System.out.println("The form for Nick is completed. We will contact you if we need a chef that cooks fusion dishes");

Input мне нужно ввести 5 параметра
 name,
 age,
education,
experience, 
fusion dishes.
Output The form for Nick is completed. We will contact you if we need a chef that cooks fusion dishes.

Ответы (2 шт):

Автор решения: Олексій Моренець

Не знаю зачем, но можно так:

    String fusion, dishes;
    fusion = dishes = scanner.nextLine();
→ Ссылка
Автор решения: Алексей г
public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine(); //Nick
        int age = scanner.nextInt();// 25
        scanner.nextLine();
        String education = scanner.nextLine(); //secondary
        int experience = scanner.nextInt(); //3
        scanner.nextLine();
        String fusion = scanner.nextLine();
        String fusionDishes = scanner.nextLine();

        System.out.println("The form for " + name + " is completed. We will contact you if we need a chef that cooks " + fusionDishes);
    }

Рекомендую почитать основы java. Это очень простые задания, так дальше далеко не уедете.

→ Ссылка