More efficient for an Java Array -


I have an assignment in which we will have to create a directory that stores the name and extension number. In the first part we have to store the information in just one array, we have to be able to add an entry in the array and initially read a .txt file and store it in array. After all, he has to print arrays. I was just wondering what would be more efficient because I had only started learning the code in the last few months and it is difficult for me. 1) Would it be better to make an array of the first size [99 99] (since it is the maximum number of entries because it can be in the directory because each has a unique four digit number). I have a count in the INNT that counts the addition of the last array [x], when I call a method like entry, it will add the entry to [x + 1].

The problem with this is that the array which I have read, is very big and can have display problems in it, apart from this, I should be able to create a 'Lookup' method which is used for any number of arrays Should be able to enter on their name. My second option: 2) When the file is read, it is counted how many lines are the file (each entry will be on its line), whenever a file creates an array of rows in the text file I want to add a new entry, I copy the array to an array list, then add a new entry back to an array. However, I have also read that copy aires is not very good and in the actual view, if someone uses this directory they can add entries every day.

As long as I store in an array and print the array in the table, it's all good, but when you do not know the size, what would be the best way to create a real array? (Yes, I know that I can use array lists, but this is not particularly called)

In addition to how you can go about deleting entry in the array, if I I use it in my own way, there will be no entry in the array [x] where x was removed.

Thank you in advance for any answers.

It is best to initialize the array of shapes that you initially Is required when you need to add items to the array after that, you can use the memory copy instead of the object clone.

  int [] arrayOne = new int [20]; Int [] arrayTwo = new int [40]; System.arraycopy (arrayOne, 0, array2, 0, arrayOne.length);   

This copy is actually very fast because it directly copies from memory, it is actually what the array of underlying code does when it doubles in size. If you want an array of "dynamic" size, you can write your own version in the array list. For example:

  • starts at size 1
  • When it is done, doubles in size
  • using the system Taxes make changes on deleted objects.

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -