Advertisement
apez1

Term 1: Lesson 30 - Coding Activity

Oct 25th, 2018
629
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.60 KB | None | 0 0
  1. public class Lesson_30_Activity {
  2.    
  3.    
  4.     public static String [] list = {"every", " near  ing ", "      checking", "food ", "stand", "value      "};
  5.     public static void main(String[] args) {
  6.        
  7.     String [] newlist = new String[list.length];
  8.    
  9.        
  10.     int c = 0;
  11.        
  12.         for(int i = 0; i < list.length; i++) {
  13.            
  14.         int length = list[i].length();
  15.                
  16.             if(list[i].contains(" ")) {
  17.                
  18.                 newlist[i] = list[i].replaceAll(" ", "");
  19.                
  20.                
  21.             }
  22.             else {
  23.                
  24.                 newlist[i]=list[i];
  25.                
  26.             }
  27.        
  28.  
  29.             System.out.println(newlist[i]);
  30.        
  31.  
  32.            
  33.         }
  34.        
  35.        
  36.        
  37.        
  38.        
  39.        
  40.        
  41.        
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement