This article delves into the difference between the next() and nextLine() methods of the Scanner class.The article also covers the use of custom delimiters and provides code examples for better understanding. Understanding these distinctions enables developers to parse input effectively using Scanner.
Also find me here:
Baeldung Author
Abderrahim Azhrioun
Full Stack Developer, Java Geek, Spring Lover, and a Blogger. I believe coding should be fun and accessible to everyone ;)
Here's what I've written (so far):
Baeldung on Java
- All
- Java Dates (9)
- Java String (8)
- JPA (7)
- Java IO (6)
- Spring Boot (4)
- Persistence (4)
- Spring Data (3)
- Java List (3)
- Jackson (3)
- Spring Web (2)
- Spring MVC (2)
- Java Streams (2)
- Java Collections (2)
- Java (2)
- Core Java (2)
- Spring Persistence (1)
- REST (1)
- Java Map (1)
- Java Array (1)
- JSON (1)
- HTTP Client-Side (1)
Java PrintStream to String
Filed under Java IO, Java String
This article provides several ways of converting a PrintStream to a String in Java.The approaches include using ByteArrayOutputStream, a custom output stream, and Apache Commons IO.
Spring Boot H2 JdbcSQLSyntaxErrorException expected “identifier”
Filed under Persistence, Spring Boot
This tutorial explains the exception org.h2.jdbc.JdbcSQLSyntaxErrorException: Syntax error in SQL statement expected “identifier”. It provides a practical example to reproduce the exception and showcases how to fix it by double-quoting the keyword or using a JDBC URL workaround. It also covers how to automatically quote all database identifiers when using Hibernate.
Check if the First Letter of a String Is a Number
Filed under Java String
This tutorial explains different ways to check if the first character of a string is a number in Java. It covers using charAt(), Character.isDigit(), Pattern class, and matches() method. It also demonstrates how to use Guava’s CharMatcher utility class to accomplish the same objective.
Fix the JsonMappingException: Can not deserialize instance of java.util.ArrayList from Object value (token JsonToken.START_OBJECT)
Filed under Jackson
Learn how to fix a common JsonMappingException when deserializing a JSON string.
Fix Spring Data JPA Exception: No Property Found for Type
Filed under Spring Data
This article explains how to fix the “PropertyReferenceException: No property found for type” in Spring Data JPA. It advises using exact property names when defining query methods to avoid the exception. Practical examples are provided.
Fix EmptyResultDataAccessException When Using JdbcTemplate
Filed under Spring Persistence
Explanation of the reason behind EmptyResultDataAccessException when jdbcTemplate is used and how to fix it.
Fix the IllegalArgumentException: No enum const class
Filed under Java
Why IllegalArgumentException is thrown and how to fix in it in Java.
Convert Anonymous Class into Lambda in Java
Filed under Core Java
A reminder of what an anonymous class is and how to convert it to a lambda expression.