October 2017
Beginner
318 pages
7h 26m
English
Perhaps, the most interesting of the String class's methods is actually one of its static methods: String.format(). To show you the power of String.format(), I'd like to create a brand new functional class for our project. So right-click on the Project name in the filesystem, shown on the left-hand side of the screen, create a new class, and call it CustomPrinter.java:
package strings;
public class Strings {
public static void main(String[] args) {
CustomPrinter printer = new CustomPrinter("> > %s < <");
String s1 = new String ("Strings are arrays of characters");
String s2 = new String ("Strings are arrays of characters");
printer.println ("string1: " + s1.replace("characters", "char")); printer.println("string2: " ...Read now
Unlock full access