Java Video Tutorial 11

preview_player
Показать описание


In this part of my Java Video Tutorial I introduce Java collection classes. Specifically I cover how to use Java ArrayLists.

Java ArrayLists make it easy to keep track of groups of objects. A Java ArrayList differs from a java array in that it automatically resizes itself when you add or remove values.

I'll go over nearly every Java ArrayList method in this video.
Рекомендации по теме
Комментарии
Автор

Thank you :) I started programming when my neighbor threw out a TRS-80. My first language was Basic. I then moved on to Assembly and Pascal. I started C++ when I was about 15. It is funny because my family used to tell me I was wasting my life on that silly toy. The funny thing is that almost nobody in my family can still use a computer. I was brought up on a farm in the middle of nowhere

derekbanas
Автор

I've watched a lot of java videos on youtube. But yours are by far (judging by this video alone) the most professional and helpful and informative videos. Thank you very very much!

Tggfredcsawsdfgbhhhhu
Автор

I have never found the need to force myself to memorize class or method names. I just use the online api until I naturally just remember the classes I use the most. Code completion in the IDE helps a lot as well.

derekbanas
Автор

Normally you'll use arrays for collections of primitives. ArrayLists and the other collections have extra overhead, so that is the reason people use arrays for primitives.

derekbanas
Автор

You are correct. I was just demonstrating everything you can do with an arraylist like a video api. Sorry if that was confusing. I cover arraylists further in this tutorial

derekbanas
Автор

You just saved my day! I wasted 10 hours trying to find out why I'm getting a damn NullPointer until this video that I noticed that I forgot to make it an instance. Now I can finally continue working on the complexity of adding and replacing files to jars or zips.

Spacebirdy
Автор

You can use the Iterator with any collection. In my next tutorial on the Iterator Design Pattern you can see that used in a real world example :) I'll try to get it up today

derekbanas
Автор

I'm very happy to help and to remain free. Hopefully some day more people will cover all of the other topics I don't and everyone can get a free education online :)

derekbanas
Автор

Thank you :) Please clarify your question. As the tutorial continues I store many different types of objects in ArrayLists. Most everything in java is an object.

derekbanas
Автор

Don't thank me till you see it :) It is an advanced tutorial. At this point I'm basically providing people with the knowledge a software engineer gets in college and maybe even graduate school. Hopefully that doesn't alienate all of my subscribers

derekbanas
Автор

public URL getResource(String name) is definitely what you need. Look for it in the java api. Make sure you store the txt file in src or a subfolder of src.

You can also do this
JarFile jarFile = new JarFile("YourJarFile")
JarEntry entry =
InputStream stream = jarFile.getInputStream(entry)

derekbanas
Автор

It's 2017 and i still refer to this tutorial. Great videos...

eesaaphilips
Автор

You're right about addAll. toArray returns an array

derekbanas
Автор

I cover ArrayLists and other topics over and over throughout this tutorial. Feel free to bounce around. If you don't quite get a video skip ahead. I do my best to explain everything each time even if I have covered that topic in the past. Have fun with it and always feel free to ask questions

derekbanas
Автор

This man is the best Java instructor I've seen on whole YouTube so far. Fast-paced, comprehensive and ambitious. Keep it up! *opening Eclipse*

fabi
Автор

Don't try to memorize everything. That will just frustrate you. When I was learning, I organized everything into a folder. I had a String folder, that contained all of the String methods and common uses. I had the same for every other core tool. The when I needed something, I'd refer to those files (that were heavily commented) and just copy and paste the code. That's what I try to do with the code on my site. After a while you just remember stuff

derekbanas
Автор

@supprof1 Thank you for taking the time to watch them. I also appreciate it when you say hi :)

derekbanas
Автор

The reason it failed is because there are 3 items in indexes 0, 1, 2. Then I use remove to get rid of one and then when removeRange is called it doesn't work. When I make these tutorials I often throw everything possible into them. If I don't run something, that just means it is there for you to experiment with. I'm sorry about the confusion

derekbanas
Автор

If you don't need the power provided by an arraylists methods stick with arrays or one of the other data structures

derekbanas
Автор

Yes an ArrayList can store any type of data, but you normally want to store the same data type. As the tutorial continues I cover how to use them in many ways

derekbanas