A Quick Summary of String Manipulation in Java - dummies

A Quick Summary of String Manipulation in Java

By John Paul Mueller

In Java programming, you can create strings from other sorts of data and create other sorts of data from strings by using the conversion methods supplied as part of the Java API. Here are the key points you need to remember about data files in Java:

  • Converting data from one type to another means changing the actual presentation and storage of the data, rather than casting it as a larger form of the same type.

  • The String type provides a number of ways to find information, including looking at a particular part of the string, comparing two strings, and working with substrings.

  • Modifying a String includes replacing string elements, extracting characters from the string, and splitting the string into pieces.

  • Formatting a String makes it more presentable to the user and also makes your application friendlier by displaying data in a form the user understands.

Here are some words you need to know when working in Java:

  • data conversion: A method of converting data between unlike types, such as String and int. When performing data conversion, Java must actually change the representation of the data so that it fits into the new type.

  • locale: The characteristics of application output that define a particular language. For example, some languages use a period for the decimal marker, while others use a comma. Formatting data with locale in mind makes it easier for people who speak other languages to use it.

  • parse: The act of breaking up a string into pieces called tokens, normally at spaces, and then analyzing each token for specific information. For example, “Java is a great language.” has five tokens, “Java”, “is”, “a”, “great”, and “language.”

  • substring: A string of characters taken from the beginning, middle, or end of a string and used as a separate entity in an application.

  • token: A single identifiable piece of information within a string. Generally, the sentence is separated by spaces into tokens, so that the sentence “Sunny days are nice!” has four tokens in it, “Sunny”, “days”, “are”, and “nice!”.