Home > Articles

This chapter is from the book

7.10 Wrap-Up

This chapter presented Java’s String, StringBuilder and Character classes. You saw various ways to create String objects, then used String methods to determine a String’s length, get characters and character arrays from Strings, compare Strings, locate characters and substrings in Strings, extract substrings, concatenate Strings, replace characters in Strings and change the case of a String. You saw that Strings are immutable, so each String operation that appears to modify a String’s contents copies the contents, performs the modification on the copy and returns a new String containing the result.

We used modifiable objects of class StringBuilder to dynamically create and manipulate String content without creating unnecessary String objects. We used class Character to test characters for various attributes. We converted between characters and their corresponding Unicode integer values and vice versa. We used the String method split to tokenize Strings—breaking text into sentences and words is a key aspect of helping computers understand natural language.

We introduced natural language processing (NLP), which helps computers understand, analyze and process text, and serves as a foundation for generative AI. We explained how we used Grammarly and generative AI’s NLP features to tune our writing, evaluate our chapters breadth and depth of coverage, verify the content and suggest improvements.

We continued our objects-natural approach with two case studies. The first introduced regular expressions—crucial in today’s data-rich applications for cleaning and preparing data for analysis, data mining and transforming data to other formats. You used String methods and the java.util.regex package’s Matcher and Pattern classes to perform these tasks. These capabilities are frequently used to validate data. They are also used in natural-language processing, preparing data for training generative AIs and helping generative AI models create responses to your prompts. In Chapter 11, we’ll do more with NLP.

In the second objects-natural case study, we used the Java Cryptography Architecture (JCA) and Java Cryptography Extensions to introduce symmetric cryptography using the popular and powerful AES encryption algorithm. In that case study, you saw how to generate secret keys, prepare plaintext for encryption, configure a Cipher for encryption, encrypt plaintext to create ciphertext, configure a Cipher for decryption and decrypt ciphertext to restore the original plaintext. Java provides extensive security and cryptography features. To study these in depth, refer to Oracle’s Security Developer’s Guide.28 We’ll continue our Objects-Natural Security Case Study with an introduction to asymmetric encryption in Chapter 11, Files, I/O Streams, JSON Serialization & CSV Files.

In the next chapter, you’ll create custom classes. You’ll see that each new class you create is a type you can use to declare variables and create objects.

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.