Array vs. ArrayList in Java Tutorial - What's The Difference?

Array vs. ArrayList in Java Tutorial - What's The Difference?

Coding with John

3 года назад

484,607 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

Algedrez4D
Algedrez4D - 11.10.2023 04:29

how do you pass in?

Ответить
Luna Rieu
Luna Rieu - 09.10.2023 21:49

Literally I was crying after my class cause the teacher really did not explain as clear as this video. Honestly, thanks a million!🥰⭐

Ответить
hennessey lei
hennessey lei - 05.10.2023 04:51

thank you for explaining this in a way that works with my brain. I felt so dumb for so long where have you been

Ответить
Kanat Muhudin Uulu Berdimuratov
Kanat Muhudin Uulu Berdimuratov - 04.10.2023 00:55

Karl 😂

Ответить
Hayet AIT OUAZZOU
Hayet AIT OUAZZOU - 03.10.2023 18:54

Thank you John for the video

Ответить
Kevin Vélez
Kevin Vélez - 27.09.2023 00:50

import java.util.ArrayList;
import java.util.Arrays;

public class App{
public static void main(String[] args) {

String[] friends = {"Kevin", "Joseph"};
friends[0] = "Karl";
System.out.println(friends[0]);
System.out.println(friends.length);
System.out.println(Arrays.toString(friends));

ArrayList<String> friendsList =
new ArrayList<>(Arrays.asList("Kevin", "Joseph"));
friendsList.set(1, "Axel");
friendsList.add(2, "Mike");
friendsList.remove("Joseph");
System.out.println(friendsList.get(0));
System.out.println(friendsList.size());
System.out.println(friendsList.get(2));
System.out.println(friendsList);

}
}

Ответить
Júš༒łη Ebenazar
Júš༒łη Ebenazar - 25.09.2023 03:40

What if when creating a array , I specify the size with a variable and then increment it later, will now be able to add more values ?


Eg:

int h= 10;
int[] arr= new int[h];
h+=1;
arr[10]=12;

Ответить
Billie B
Billie B - 19.09.2023 18:24

as I was watching I thought "BUT-BUT you cant DO THAT!" and then you wrote "//you can't do that "
and i got just a nice ass dopamine hit, thank you.

Ответить
Ziona Sohun
Ziona Sohun - 16.09.2023 13:24

Hi John. Thank you for these teachings. I really appreciate it.

If I may ask... Can you think of a case one would have to use an array.

Ответить
Alvin Ashneel
Alvin Ashneel - 25.08.2023 11:34

Bruh
. Hope you gain a ton more subscribers asap.. ur the reason i started learning Java..

Ответить
Ayoub ElGueddari
Ayoub ElGueddari - 21.08.2023 22:10

Great video

Ответить
Vyshnav K S
Vyshnav K S - 19.08.2023 19:34

Mr.John, passing the code you wrote in the first comment could be a great way to make hands dirty!

Ответить
John Henry
John Henry - 12.08.2023 05:38

Thanks for this video. I googled ArrayList and Linked list and got a LOT of sites but non of them made sense to me and a few of them just made me more confused.

Ответить
CodingMyWayUp
CodingMyWayUp - 07.08.2023 12:59

corl

Ответить
Football player⚽️🎵
Football player⚽️🎵 - 05.08.2023 02:10

you are my hero man, I've been using fixed array my whole life, you're best than my professors in college

Ответить
XkriPt
XkriPt - 23.07.2023 19:36

super explained, with respect from Germany🙏

Ответить
Roma_Ethereal
Roma_Ethereal - 22.07.2023 12:31

stop wait
Why can't I delete items from an array?
The leetcode even shows how to insert an element to the beginning, end, and middle of an array, and how to delete these elements

Ответить
Carl Pilongo
Carl Pilongo - 22.07.2023 09:00

I feel like he is calling me

Ответить
Aliyu Ibrahim
Aliyu Ibrahim - 13.07.2023 16:13

Clear explanation

Ответить
Jan
Jan - 06.07.2023 05:01

Carl

Ответить
Blood Bath and Beyond - Pop Goes Metal Covers
Blood Bath and Beyond - Pop Goes Metal Covers - 01.07.2023 00:31

You shouldn't lie to people about printing arrays. It makes biased and lacking in credibility.
You literally said that ArrayList implements the Arrays.toString() method. Meaning that if you use Arrays.toString on your array, it will print just like the ArrayList. I thought you were trying to educate, not spread bias over such an arbitrary topic to be biased over.

Ответить
Blood Bath and Beyond - Pop Goes Metal Covers
Blood Bath and Beyond - Pop Goes Metal Covers - 30.06.2023 07:38

It blew my mind when I learned that you can resize an array by making a copy of it with Arrays.copyOf().
Worked great for a solution where I needed to break an input string into parts, but some of the parts ended early.
If the scanner.nextLine() only made a String array of length 2, copyOf and resize it to 3!

Ответить
Henrique Shimada
Henrique Shimada - 28.06.2023 19:09

Yeah, although showing the ArrayList implementation could be a little advanced for beginners, it could be a good strategy to learns about data structure and solution learning. Under the implementations, those are methos that manipulates arrays, so it would be even more clear to understand how ArrayList deals with this data structure. Anyways, good video for learning some basics

Ответить
Blacktician
Blacktician - 28.06.2023 01:36

Thanks again this is exactly what I needed coming from more user-friendly languages

Ответить
Wayne Interessierts
Wayne Interessierts - 23.06.2023 12:41

Man, John! Thank you so much! I‘m about to start my first developer job and see your videos daily! You are so great help!!! Please keep going!

Ответить
Renee Mason
Renee Mason - 13.06.2023 20:42

Thanks John, perfect info. Sorry to Chris who got removed haha

Ответить
Гульхаё Мусурмонова
Гульхаё Мусурмонова - 11.06.2023 13:11

Thank you so much))

Ответить
Rob Ross
Rob Ross - 09.06.2023 09:45

I’ve been using Collection Lists for so long, I forgot that the Java Array was fixed size! 😂 Thanks for the reminder.

Ответить
PhaxCraft
PhaxCraft - 08.06.2023 20:15

One main thing that arrays might have direct use for is situations where boxed types cause issues with getting the expected result (eg. - int vs Integer). Since arrays can use primitive types and array lists cannot it might be ideal to use an array instead in that situation despite the more tricky implementation. Not sure how to explain that any better but that might be a good topic to cover if you don't already have a video of that sort. Still poring over a lot of content here but loving this channel 😁

Ответить
John ChukwuOrji
John ChukwuOrji - 06.06.2023 21:33

Hi, John.
I had recently joined an ICT institute.
Please I kindly need your help with Java and the basics of the program that I can start with.
Please your advice will highly be helpful to me.
Thanks in anticipation.

Ответить
Leonardo Cuevas
Leonardo Cuevas - 28.05.2023 01:36

I'm working on an adaptation of 2 REST API I did on Node with MongoDB to Spring Boot with MySQL. But every once in a while it's great go back to the hows and whys of Java. 👏👏👏

Ответить
Egor Vafin
Egor Vafin - 26.05.2023 13:56

Thank you for this video

Ответить
Sambhav Kumath
Sambhav Kumath - 18.05.2023 17:31

thanks for making such an awesome lecture. hoping for more such tutorials

Ответить
Stephen Cameron
Stephen Cameron - 17.05.2023 22:46

You explained the difference real well, but I find the advice unusual
Use what is most suitable for the task, not "ArrayList because it is more capable"

Ответить
blaze
blaze - 09.05.2023 16:00

thank you so much ! great content (including the joke at the end haha)

Ответить
aravindh kumar
aravindh kumar - 07.05.2023 10:10

You are really superman.. Because your video helpful to everyone... I saw a video from tamilnadu in south India....... Your are my best teacher

Ответить
Santosh Gavhane
Santosh Gavhane - 25.04.2023 17:42

perfect!

Ответить
Ayan Khanra
Ayan Khanra - 23.04.2023 07:24

somebody pls let me know if there is a complete collection framework available by our beloved jhon

Ответить
Narasimha Raju
Narasimha Raju - 18.04.2023 08:44

Need justice for chris 😢

Ответить
Srihari Vernekar
Srihari Vernekar - 12.04.2023 18:15

Amazing video, thank you so much.

Ответить
Cosmos
Cosmos - 11.04.2023 16:18

Having spent a semester learning and working with C (and now learning Java in my CS classes), I have to say that the dynamic size of array lists sure does have me excited :D

Ответить
Megatr0n12
Megatr0n12 - 11.04.2023 02:02

Do you have content that goes through how Java resizes ArrayLists? how about the space and time complexity of the inserts and deletes?

Ответить
Megatr0n12
Megatr0n12 - 11.04.2023 01:46

Do you have any content talking about the performance implications of Unboxing and Autoboxing data types in Collections? In this video you seem to quite casually suggest using Object type wrapper for primitive classes but i've found under some situations there's a performance hit with using those instead of the primitive types?

Ответить
Cashew
Cashew - 28.03.2023 16:05

Great vid!

Ответить
Aman Motghare
Aman Motghare - 28.03.2023 08:51

Johnny Sins is really a great java teacher

Ответить
Aline Sinclaire
Aline Sinclaire - 24.03.2023 01:53

I am in love with your videos!

Ответить
Marco Valentino Alvarado
Marco Valentino Alvarado - 17.03.2023 01:12

Just like Python has a Sentdex, Java has a John 💞💞 You guys are awesome!

Ответить
Edwin Saga
Edwin Saga - 13.03.2023 11:17

Awesome way of teaching John.. please don't stop teaching at any cost. This really helps a lot of people !! you deserve more subscribers

Ответить