O'Reilly logo

Java Garage by Eben Hewitt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Useful String Methods

In keeping with the habit I'm trying to develop, of focusing on code that you can run and change and mess around with, and get you in the habit of doing instead of reading, let's just plunk down some code that shows off some of the useful methods of the java.lang.String class.

StringDemo.java

 package net.javagarage.demo.String; /** <p> * Demonstrates how to use Strings to your advantage. * </p> * @author HewittE * @since 1.2 * @version 1.0 * @see **/ public class StringDemo { private static void print(String s){ System.out.println(s); } private static void print(char c){ System.out.println(c); } private static void print(int i){ System.out.println(i); } private static void print(boolean b){ System.out.println(b); } public ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required