how to increase an regular array length in java?
2014-09-16 16:20
351 查看
Arrays in Java are of fixed size that is specified when they are declared. To increase the size of the array you have to create a new array with a larger size and copy all of the old values into the new array.
ex:
ex:
//declare an array at first Object[] myStore= new Object[10]; //now if I almost use up all spaces of myStore, I can create a new one with double length myStore = Arrays.copyOf(myStore, myStore.length*2); //the original one will be garbage collected by jvm
相关文章推荐
- How to Check if an Array Contains a Value in Java Efficiently?
- How to Check if an Array Contains a Value in Java Efficiently?
- How to Check if an Array Contains a Value in Java Efficiently?---reference
- In Java, how do I read/convert an InputStream to a String? - Stack Overflow
- How to define an array in c#.
- How to Convert Array to ArrayList in Java?
- How to call different methods as given in an array
- an oracle article in high level to descibe how to archtichre operator JAVA relevet project
- HOWTO: How to Provide Your Own DllMain in an MFC Regular DLL
- How do you copy the contents of an array to a std::vector in C++ without looping? (From stack over flow)
- How to convert char array to String in Java
- How to Write an Equality Method in Java(之三)Java中如何写equals()方法
- How to sort an array in Ruby to a particular order?
- How to get the length of array of strings in C? - Yahoo! Answers
- How to increase Memory usage for an App in Windows Phone
- How to sort an NSMutableArray with custom objects in it?
- how to remove nil and blank string in an array in Ruby
- How to group anagrams in a string into an array
- How to find number of a specific integer in an array of Fixnums ruby
- How to Iterate over Array in Java 1.5 using foreach loop Example