Powered by Blogger.

Java - Specification of Array Resizing

Specification of Array Resizing:

One thing I really love about this blog is that it's a wonderful learning experience. I think too many of us rely on things like “manuals,“ “books,“ and even “best practices“ to guide our programming and software development. For example, if I was developing an application in Visual Basic 6 and needed to resize an array, I would just ReDim it. I'll even go so far as to say that I couldn't think of a different way to handle that situation. But not Matt Hawley's colleague. I think he's just born to think out of the box.

Array Resizing Example:-

 public void arrayResizing(){
 int[]arr=new int[10];
 arr = new int[5];
 }

Others Example:-

public String[] increaseArray(String[] theArray, int increaseBy) 
    { 
        int i = theArray.length; 
        int n = ++i; 
        String[] newArray = new String[n]; 
        for(int cnt=0;cnt<theArray.length;cnt++)> 
        { 
            newArray[cnt] = theArray[cnt]; 
        } 
        return newArray; 
    } 

1 comment: