Check06C - pattern ="[0-9"...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
import java.io.PrintStream; i public class Check06C { public static void main(String[] args) { PrintStream out = System.out; if (args.length < 1) { out.println("Usage: java Check06C <string>"); } else { String pattern = "[A-Za-z]+"; if (!args[0].matches(pattern)) { out.println("The string must consist of letters!"); } else { StringBuffer sequence = new StringBuffer(args[0]);
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: pattern = "[0-9]"; while (!sequence.substring(0, 1).matches(pattern)) { String c = sequence.substring(0, 1); int lastIndex = sequence.lastIndexOf(c) + 1; sequence.delete(0, lastIndex); sequence.append(lastIndex + c); } out.println(sequence); } } } }...
View Full Document

This note was uploaded on 09/16/2011 for the course CSE CSE 1020 taught by Professor Burton,ma during the Fall '10 term at York University.

Ask a homework question - tutors are online