Buradasın
Scanner next() vs nextLine() Methods
baeldung.com/java-scanner-next-vs-nextlineYapay zekadan makale özeti
- Scanner Overview
- Scanner class breaks input into tokens using default whitespace delimiter
- Scanner reads input from consoles and files
- next() Method
- Reads next token until encountering delimiter
- Multiple whitespace characters treated as single whitespace
- Custom delimiter can be specified using useDelimiter() method
- nextLine() Method
- Reads entire line including whitespace until newline character
- Stops reading after newline or enter key
- Cursor moves to next line after reading
- Custom delimiter doesn't affect nextLine() behavior
- Alternatives
- String.split() can be used as alternative tokenization mechanism
- Split(regex, int limit) splits string with specified pattern
- Split(regex) splits string without limit