java - deleting an object from an array -


There is an array of objects of my custom class and I want to delete a random object (selected by certain criteria). How can I do this and order the array? Naturally, the elements will be transferred on the left side, but it is not enough to remove the element and I need help in preparing the argument. This is what I am doing but it does not work properly for this: (

  public static zero deletion record (customer [] record, intexide) {int pos = 0 ; // Indicator Boolean found = false; for (int i = 0; i & lt; count; i ++) {// If there is number of elements in the count (record [i] .get_accountid () == AccId) {Found = true; pos = i; break;}} If (found!) For System.out.println ("record does not exist") (int j = paus + 1; j & lt; count; j + +) {Record [J-1] = Rick [J];}    

You can only move elements left because This will be overwrite items for deletion.

  Generate public zeros (object [] A, index index) {for (int i = index + 1; i & lt; a.length Assume that the first  null   / Code> indicates the end of the elements.  

Of course, this is the time of O (n) and the data structures such as Linkedlists are O (1) In summer you can remove elements.

Comments

Popular posts from this blog

qt - switch/case statement in C++ with a QString type -

python - sqlite3.OperationalError: near "REFERENCES": syntax error - foreign key creating -

Python's equivalent for Ruby's define_method? -