Advertisement
WinSide

Untitled

Oct 25th, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.71 KB | None | 0 0
  1. public class CustomType2 {
  2.     private String sentense;
  3.  
  4.     public CustomType2() {
  5.        
  6.     }
  7.  
  8.     public CustomType2(String string) {
  9.         this.setSentense(string);
  10.     }
  11.  
  12.     public CustomType2(CustomType2 ct2) {
  13.         this.setSentense(ct2.getSentense());
  14.     }
  15.    
  16.     public void removeSingleWord (){
  17.         String[] temp = this.getSentense().split("\\s|,");
  18.         this.setSentense("");
  19.         for(int i = 0; i < temp.length; i++){
  20.             if(temp[i].length() == 1 && !temp[i].isEmpty()){
  21.                 this.append(temp[i]);
  22.             }
  23.         }
  24.     }
  25.  
  26.     public String getSentense() {
  27.         return sentense;
  28.     }
  29.  
  30.     public void setSentense(String sentense) {
  31.         this.sentense = sentense;
  32.     }
  33.    
  34.     public void append(String sentense) {
  35.         this.sentense += sentense + " ";
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement