Advertisement
Guest User

Untitled

a guest
Feb 27th, 2012
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.79 KB | None | 0 0
  1. public class Easy16 {
  2.  
  3.     /**
  4.      * @param args
  5.      */
  6.     public static void main(String[] args) {
  7.         Scanner s = new Scanner(System.in);
  8.         System.out.println("What string do you want to remove letter from?");
  9.         String input = s.nextLine();
  10.         System.out.println("What do you want to remove?");
  11.         String remove = s.nextLine();
  12.         System.out.println(letterKiller(input, remove));
  13.     }
  14.    
  15.     private static String letterKiller(String string, String remove){
  16.         StringBuffer resultString = new StringBuffer("");
  17.         for(int i=0; i<string.length(); i++){
  18.             for (int j= 0; j<remove.length();j++){
  19.                 if(string.charAt(i)==remove.charAt(j)){
  20.                     break;
  21.                 }else if(j==remove.length()-1){
  22.                     resultString.append(string.charAt(i));
  23.                 }
  24.                
  25.             }
  26.            
  27.         }
  28.        
  29.         return resultString.toString();
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement