Alert icon
We're changing our privacy policy. This stuff matters.  Learn more  Dismiss

Java 08: Advanced Arrays

Loading...

Sign in or sign up now!
44,334
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on May 13, 2007

How to unroll and append elements to an array.

Java 1.6
Netbeans 5.5.1 beta

Category:

Howto & Style

Tags:

License:

Standard YouTube License

  • likes, 10 dislikes

Link to this comment:

Share to:

Uploader Comments (gorilla3d)

  • Netbeans is a great IDE so is Eclipse just a matter of taste.

Top Comments

  • Well, nice tutorial about how NOT TO use arrays in Java.

    1., the worst thing you can do is to allocate memory for a larger array every time you want to add a new element to it. Have a look at the source code of the ArrayList class, and see that it operates on arrays behind the scenes. The best practice is to check whether there is enough space for the new element before you insert, and double the size once it is full.

    2. java.util.Arrays.copy -- most cost-effective way of copying values

  • Minor thing.... you use the word "Integer" to describe your 'int array' there is a difference between 'int' and 'Integer'.... an 'int' is a primitive data type an 'Integer' is the wrapper clas that allows you to treat int's like objects not really that important but this differnce could confuse people if they go into the complexities of java programming

see all

All Comments (35)

Sign In or Sign Up now to post a comment!
  • whereisthespacebar?

  • You do this and that and throw in some lightbulbs and Bam... Beautiful Explanation on how to use ARRAYs, but I still think I should look more into it

  • @JUanBOBO You are right..

  • why to you have to convert the array element into a String? i don't see the point because if you out put the integer it would still be 11.

  • @stedav WRONG! If you add to an array beyond it's specified size, you will get an ArrayIndexOutOfBounds runtime exception. Go learn java.

  • this motherfucker doesn't know anything, ha ha....

  • dude am soo confused

    please explain

  • I am sorry, but I agree with most of the comments bellow. You just type and lack in explanation. =\

  • Don't just speak what you're typing. Explain what you're doing and why..what this video is, soforth. Come on, man.

  • BigE76 is absolutely correct, the confusion from this tutorial is evident. An int is a primitive type, and the Wrapper class Integer is an Object, with different behavior for each. The Wrapper class Integer has a default value of null, whilst the int is 0; this is a big difference in Arrays.t Further the size attribute in an array is a guide to the compiler about the minimum length, if you wish to add to the array you don't need to reassign the reference to a new array!

Loading...

0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more