다음 코드에서 키보드에 y를 입력하면 분기 문의 else 부분에 입력됩니다. 왜 그런가요?Java 입력이 문자열을 인식하지 못합니다.
public static void getInput(){
String response;
String[] coins = new String[6];
System.out.println("Would you like to enter your own amount? (y/n)");
Scanner sc = new Scanner(System.in);
response=sc.nextLine();
if (response=="y"){
System.out.println("You entered y");
}
else{
System.out.println("You did not enter y, you entered " + response);
}
}
이 프로그램 ... – Vinoth