Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

public class Main {

    public static void main(String args[]) {
        System.out.println(stripGarbage("A good String"));
    }

    public static String stripGarbage(String s) {
        String good = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
        String result = "";
        for (int i = 0; i < s.length(); i++) {
            if (good.indexOf(s.charAt(i)) >= 0)
                result += s.charAt(i);
        }
        return result;
    }
}