java - type mismatched from int to ArrayList -
i need help. programming polymorphism, , here stipulation homework. willing take advice on how it.
stipulation of homework: write method removes duplicate elements array list of integers using following header:
public static void removeduplicate(arraylist list)
write test program prompts user enter 10 integers list , displays distinct integers separated 1 space. here sample run:
enter ten integers: 10 20 30 20 20 30 50 60 100 9
the distinct integers are: [10, 20, 30, 50, 60, 100, 9]
here code far:
    import java.util.arraylist;     import java.util.scanner;  public class arrayinput extends arraylist{ public static int a[];  public static int[] inputarrays(int a[]) {     for(int = 0; < 10; i++) {         scanner input = new scanner(system.in);         a[i] = input.nextint();         }     return a; }  public static void removeduplicate(arraylist list) {     for(int = 0; < 10; i++) {         if(a[i] != a[i--] ) {             list = a[i];         }     }  }  }      
you can not convert or cast array of int arraylist if want add elements list, can this:
public static void removeduplicate(arraylist list) {     for(int = 0; < 10; i++) {         if(a[i] != a[i--] ) {             //change code here             list.add(a[i]);         }     } }      
Comments
Post a Comment