Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. //Convert the string into an int
  2. num = Integer.parseInt(inputField.getText());
  3.  
  4. // Add it to the an index
  5. array[index] = num;
  6. // Increment the index variable
  7. index++;
  8. // If the the duplicate exists
  9. for(int i = 0; i < array.length;i++){
  10. if(array[index] == num){
  11. if(array[i - 1] == num){
  12. JOptionPane.showMessageDialog(null,"Array may not contain duplicates ","Array Duplicate",JOptionPane.ERROR_MESSAGE );
  13. break;
  14. }
  15. }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement