Parsing Strings To Primitive Types in Java
Learn how to parse Java strings into primitive types such as int, long, double and boolean, with examples and what happens when the input is not valid.
Learn how to parse Java strings into primitive types such as int, long, double and boolean, with examples and what happens when the input is not valid.
Learn Java string formatting with the %s, %d and %f specifiers: how to insert strings, integers and decimals into text, with practical examples of each.
Learn how to trim, replace and split Java strings: remove extra whitespace, swap out characters and break text into parts with the standard String methods.
Learn how to search and index Java strings: find characters and substrings, check where they appear and read positions with the standard String methods.
Learn how to iterate over a Java String using loops, walking through its characters one at a time with clear examples of each approach in this lesson.
Learn how to extract a substring from a string in Java: how the start and end positions work, with practical examples of using the substring method.
Learn the ways to concatenate strings in Java, from the plus operator to the concat method, and when each one is the right choice for your own code.
Learn how to compare strings in Java: why == and equals differ, how to compare by content, how to ignore case and how to order strings with compareTo.
An overview of the most useful Java String methods, grouped by what they do, so you know which one to reach for when searching, changing or comparing text.
Learn how Java manages memory for strings: where they live, how the String Pool saves space and what this means for the performance of your Java code.