현재 프로그램에서 한 방법은 사용자에게 제품 설명을 String
입력으로 입력하도록 요청합니다. 그러나 나중에이 정보를 인쇄하려고 시도하면 String
의 첫 번째 단어 만 표시됩니다. 이것의 원인이 무엇일까요? 스캐너는 줄 대신 첫 단어 만 읽습니다.
void setDescription(Product aProduct) {
Scanner input = new Scanner(System.in);
System.out.print("Describe the product: ");
String productDescription = input.next();
aProduct.description = productDescription;
}
그래서 사용자의 입력이 "오렌지 맛과 스파클링 소다"인 경우,
System.out.print
는 "반짝"을 얻을 것입니다 다음과 같이 나의 방법이다.
도움이 될 것입니다.
나를 이길 때, 8 초 +1 –
굉장합니다. 고마워요! 이것은 일했습니다 :) – Kristian