php editor Xinyi answers common questions in Java programming: "Error: Symbol not found in user input code". This error usually means that the compiler does not recognize a variable or method used in the code, possibly due to spelling errors, scoping issues, or not importing the relevant package. When you encounter this situation during programming, you need to carefully check the code to ensure that all variable and method names are correct. Also, make sure you import the required packages and libraries to avoid this error.
Question content
I am very new to programming languages and I am trying to learn java language.
I'm dealing with user input, conditions and multiple conditions.
When I try to write my own code, I get an error, this is the code:
import java.util.scanner; public class main { public static void main (string[] args) { scanner input = new scanner(system.in); system.out.println("masukkan suhu:"); int temp = input.nextint(); system.out.println("masukkan hal yang direbus:"); **string rebusan = input.nextln();** if ((temp == 100) && (rebusan == "air" || rebusan == "air")) { system.out.println("mendidih, segera angkat!"); } else if ((temp >= 60 && temp <= 100) && (rebusan == "air" || rebusan == "air")) { system.out.println("sedikit lagi"); } else if ((temp >= 25 && temp <= 60) && (rebusan == "air" || rebusan == "air")) { system.out.println("masih lama, sabar"); } else if ((temp >= 1 && temp <= 25) && (rebusan == "air" || rebusan == "air")) { system.out.println("baru dinyalain..."); } else if ((temp >= -300 && temp <= 1) && (rebusan == "air" || rebusan == "air")) { system.out.println("beku!"); } else { system.out.println("hmm..."); } } }
error message:
main.java:11: error: cannot find symbol string rebusan = input.nextln(); ^ symbol: method nextln() location: variable input of type scanner
I don’t understand what I should do and what problem I should solve. Is it the dot symbol after "input"? When I remove it it doesn't work either.
Sorry for my bad English.
But when I remove the "ln" in "input.nexln();". it works. I don't understand it at all. This is the code:
import java.util.Scanner; public class Main { public static void main (String[] args) { Scanner input = new Scanner(System.in); System.out.println("Masukkan Suhu:"); int temp = input.nextInt(); System.out.println("Masukkan Hal yang direbus:"); **String rebusan = input.next();** if ((temp == 100) && (rebusan == "air" || rebusan == "Air")) { System.out.println("Mendidih, segera angkat!"); } else if ((temp >= 60 && temp <= 100) && (rebusan == "air" || rebusan == "Air")) { System.out.println("Sedikit lagi"); } else if ((temp >= 25 && temp <= 60) && (rebusan == "air" || rebusan == "Air")) { System.out.println("Masih lama, sabar"); } else if ((temp >= 1 && temp <= 25) && (rebusan == "air" || rebusan == "Air")) { System.out.println("Baru dinyalain..."); } else if ((temp >= -300 && temp <= 1) && (rebusan == "air" || rebusan == "Air")) { System.out.println("Beku!"); } else { System.out.println("Hmm..."); } } }
Workaround
You are getting this error because the scanner class does not have a method named nextln()
, the method that should be used to read the input is nextline()
.
The correct code is:
Scanner input = new Scanner(System.in); System.out.println("Masukkan Suhu:"); int temp = input.nextInt(); System.out.println("Masukkan Hal yang direbus:"); String rebusan = input.nextLine(); if ((temp == 100) && (rebusan == "air" || rebusan == "Air")) { System.out.println("Mendidih, segera angkat!"); } else if ((temp >= 60 && temp <= 100) && (rebusan == "air" || rebusan == "Air")) { System.out.println("Sedikit lagi"); } else if ((temp >= 25 && temp <= 60) && (rebusan == "air" || rebusan == "Air")) { System.out.println("Masih lama, sabar"); } else if ((temp >= 1 && temp <= 25) && (rebusan == "air" || rebusan == "Air")) { System.out.println("Baru dinyalain..."); } else if ((temp >= -300 && temp <= 1) && (rebusan == "air" || rebusan == "Air")) { System.out.println("Beku!"); } else { System.out.println("Hmm..."); } }
The above is the detailed content of Error: symbol not found in user input code. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Dreamweaver Mac version
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.
