We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
When we create an initial array of size N inputs, we exclude the possibility of invalid email ids entered by the user.
So our regex string helps to filter out the invalid email ids and we store the valid email ids in a new array location and also keep a counter k in check to find the number of entries in the new array.
After this, we create a new array 'names2' which contain k no of entries and make sure that all the array locations are filled. We do this because Arrays.sort does not work on null memory locations which we might have created if some invalid email ids have been filtered out in the process. Hope this helps!
Day 28: RegEx, Patterns, and Intro to Databases
You are viewing a single comment's thread. Return to all comments →
When we create an initial array of size N inputs, we exclude the possibility of invalid email ids entered by the user. So our regex string helps to filter out the invalid email ids and we store the valid email ids in a new array location and also keep a counter k in check to find the number of entries in the new array. After this, we create a new array 'names2' which contain k no of entries and make sure that all the array locations are filled. We do this because Arrays.sort does not work on null memory locations which we might have created if some invalid email ids have been filtered out in the process. Hope this helps!