I forgot to add a get() method for random access 🤦♂️ I've included that in the code posted here... public class Main{ public static void main(String[] args) { DynamicArray dynamicArray = new DynamicArray(5); dynamicArray.add("A"); dynamicArray.add("B"); dynamicArray.add("C"); //System.out.println(dynamicArray.get(0)); //dynamicArray.insert(0, "X"); //dynamicArray.delete("A"); //System.out.println(dynamicArray.search("C")); System.out.println(dynamicArray); System.out.println("size: " + dynamicArray.size); System.out.println("capacity: " + dynamicArray.capacity); System.out.println("empty: " + dynamicArray.isEmpty()); } } public class DynamicArray { int size; int capacity = 10; Object[] array; public DynamicArray() { this.array = new Object[capacity]; } public DynamicArray(int capacity) { this.capacity = capacity; this.array = new Object[capacity]; } public Object get(int index) { return array[index]; } public void add(Object data) { if(size >= capacity) { grow(); } array[size] = data; size++; } public void insert(int index, Object data) { if(size >= capacity) { grow(); } for(int i = size; i > index; i--) { array[i] = array[i - 1]; } array[index] = data; size++; } public void delete(Object data) { for(int i = 0; i < size; i++) { if(array[i] == data) { for(int j = 0; j < (size - i - 1); j++){ array[i + j] = array[i + j + 1]; } array[size - 1] = null; size--; if(size
@K86-j4y3 жыл бұрын
Can u make a swift all in 1 course plssss
@macklykyn89672 жыл бұрын
You forgot the clear() method, public static void clear(){ array=null; size=0; } thank you sir for your explanation
@joyceasante8292 Жыл бұрын
Practicing... import java.util.*; public class Main { public static void main(String[] args) { DynamicArray dynamicArray = new DynamicArray(); //System.out.println(dynamicArray.capacity); dynamicArray.add("1"); dynamicArray.add("2"); dynamicArray.add("3"); dynamicArray.insert(0,"0"); dynamicArray.delete("") System.out.println(dynamicArray); System.out.println("size: " +dynamicArray.size); System.out.println("capacity: " +dynamicArray.capacity); System.out.println("empty: " +dynamicArray.isEmpty()); } } *************** public class DynamicArray{ int size; int capacity = 15; Object[] array; public DynamicArray(){ this.array = new Object[capacity]; } public DynamicArray(int capacity){ this.capacity = capacity; this.array = new Object[capacity]; } public void add(Object data){ if(size >= capacity){ grow(); } array[size] = data; size++; } public void insert(int index, Object data){ if(size >= capacity){ grow(); } for(int i = size; i > index; i--){ array[i] = array[i-1];//Shifting all elements to the right } array[index] = data; size++; } public void delete(Object data){ for(int i = 0; i < size; i++){ if(array[i] == data){ for(int j = 0; j < (size - i + i); j++){ array[i + j] = array[i + j + i]; } array[size - 1] = null; size--; if(size
@s.w.51693 жыл бұрын
I hope you will continue this series. It's just amazing!
@BroCodez3 жыл бұрын
Thanks! I will be, this playlist will probably have close to 20-ish videos
@BN-cr3el3 жыл бұрын
Best videos on Data Structure & Algorithm. Thank you for making them!
@MarshGames2 жыл бұрын
This is so sick. Thank you for taking the time to explain and build a working ArrayList. I love people like you that explain things with both graphics and code. I have 0 questions about a topic when you put it together this organized. And the code in the comments (and the commented explanations)... 😙👌
@shaistakamran40593 жыл бұрын
great LECTURE. still need to see this over again. love your lectures.
@BroCodez3 жыл бұрын
Np! Thanks for watching Fahad!
@SomduttaSomSinha2 жыл бұрын
What's the difference between making instantiating array as Object[] array and making the class able to hold generic objects using Java generics (i.e. public class DynamicArray)? If we use Object[], wouldn't we have to cast elements to its actual type when retrieving them (e.g. int first = (int) array[0])?
@wintutorials22827 ай бұрын
TU delft??
@malekmousa11933 жыл бұрын
Can you make a video on Java Streams. I would really appreciate it ❤️
@shubhamsonar18163 жыл бұрын
❤️Thanks bro for.....................
@torekalanae_10 ай бұрын
in the .toString() (assuming that you didn't use StringBuilder), wouldn't it be much more efficient and faster by using this?: String string = ""; for(int i=0;i0){ string += ", "; } string += array[i]; } return "[" + string + "]"; instead of doing this?: for(int i=0;i
@phyusinlin574 Жыл бұрын
Thank you so much for providing this enlighting tutorial.
@neil_armweak3 жыл бұрын
Currently having java as main programming language in my college, and your videos are really helpful. Thanks!
@Daaninator3 жыл бұрын
hey brocode. Just a tip for your next videos. If you are going to import images in to your project is it possible to make a link in the descriptions to download the same objects? It's pretty annoying or even sometimes impossible to find an image with the same size etc... just a tip love ur videos:) also make new java videos; if you got time;)
@AbhijeetKumar-cm3jh3 жыл бұрын
Yayy, Was waiting for it, your explanations are really great, thanks :)
@sihleeundefined12083 жыл бұрын
Hey bro this tutorial was long and BOOM THANKS BEEN HERE SINCE THE ROBOT SOUNDTRACK🤣
@conradpierce89943 жыл бұрын
very glad to see your views increasing :) you deserve it and I'm happy that people finally found this gem.
@dre1997ful3 жыл бұрын
I feel like in some instances with coding you just have to accept the information and be like well idk why but it works so it works for me? lol
@ianwanjala8621Ай бұрын
nice one bro
@keenlearner18912 жыл бұрын
In add method, we have to put if condition after size++ for condition of size==capacity
@Rumen353 жыл бұрын
Thanks bro! Very good and easy to understand explanations
@sadasasdas84673 жыл бұрын
Such as amazing video. This helped me out heaps! thanks. Subscribed !
@oswallt06 Жыл бұрын
Thanks for this video. It was interesting to see you implement a custom dynamic list rather than just using Java's ArrayList.
@MrDwaynecasey19 күн бұрын
I was coming at this from a C angle... I just noticed you weren't in VS code. Eclipse for Java. Got it.
@Quran_24997Ай бұрын
You Can do this in delete method to be easy to understand public void delet(Object data) { for (int i = 0; i < size; i++) { if (array[i]== data){ for(int j =i ; j < size; j++){ array[j]= array[j+1]; } array[size-1]= null; size--; } } }
@tnkabtus2 жыл бұрын
i love your videos, they're so easy to watch and understand. thank you.
@ibrahimkhaliltoure785 Жыл бұрын
That was valuable ! Thank you sir for the great work👍🏾
@Naz-yi9bs3 жыл бұрын
Don't know Java yet trying to understand it with little bit of Python knowledge I have, thank you for the video.
@attalaw363 жыл бұрын
nice sound and very good lession thank you
@ayman85093 жыл бұрын
remember when your channel was 11k subs? me niether Good Job, Keep it up
@BroCodez3 жыл бұрын
hey ayman! Yeah it's been a heck of a ride
@panagiotiskougioumtzidis91143 жыл бұрын
You are doing really great!
@jianxi3 жыл бұрын
Hey, not sure whether am i wrong or not but for the DELETE function, i think we forgot to handle 'what if the DATA happened to be INDEX 0' So maybe we should add an IF statement for when INDEX == 0 if( i == 0) { for (int x = 0 ; x < size ; x ++) { array[x] = array[x + 1]; } break; }
@Cloud-pc8id2 жыл бұрын
I made this delete method and somehow it worked public void delete(Object data) { for(int i = 0; i < size; i++) { if(array[i] == data) { for(int j = i; j < size; j++) { array[j] = array[j + 1]; } if(size
@yeonve3 жыл бұрын
Thanks bro I like a video like this and tutorial KEEP IT UP 💓💓💆♂️
@cartoonworld35763 жыл бұрын
Love you brooo.from Bangladesh
@hray10053 жыл бұрын
I dont understand how for(int i = size; i > index; i--) { array[i] = array[i - 1]; } works. from my understanding it should push all the values to the left because its subtracting but it pushes them to the right, i have no clue how this works
@joa57242 жыл бұрын
We are keeping i = size ( i.e,last index +1). let's say the size is 4 and we have to insert data in index 2 when i = 4 ..the data in index 3 (i-1) will get copied in index 4 (i) i--; now i=3 ...the data in index 2(i-1) will get copied in index 3 (i ) i--; now i = 2 is not greater than index which we have passed in ( which is 2) the loop terminates. then we can insert the data like array[ 2] = data ;
@heayyyyyyy113 жыл бұрын
Thank you. Very useful ;)
@Muhammadfaisal-kd9kx10 ай бұрын
thankyou bro great content as always
@ronaldrabanes40833 жыл бұрын
bro, do you videos for databases, ex: mysql. tnx bro.
@Noble_Savage2 жыл бұрын
Sweet video, tanks!
@ledsonvanini74212 жыл бұрын
Fantastic. Tank you so much!
@babyfeavel71 Жыл бұрын
You bring back the joy of code. Feel's good to see relaxing tutorials just solving problems🌻
@kugi77863 жыл бұрын
Thank you, great explonation.
@farmgatebd78583 жыл бұрын
i'm just waiting for full-course video ,,,, offline is better to watch for me. i'v all collection of full. very thank you .... i also reqst to make video on algorithm by easy representation. good DataStructur and Algorithm video is very rare in youTube.
@youness15543 жыл бұрын
I love you bro from Morocco
@youness15543 жыл бұрын
👨💻👍👌
@wolanus3 жыл бұрын
Great video!
@pragmaticcoder69107 ай бұрын
What are the chances of asking to build a dynamic array in FAANG interview? Ideally for me it'll take time to ace this algorithm appropriately.
@victorrezende600211 ай бұрын
Nice Class
@aditya_asundi3 жыл бұрын
Woah cool
@wzup234 ай бұрын
Dude why does it automatically converts the input to string without calling toString() method? Thanks
@unknown-rd3kv Жыл бұрын
Thanks bro 🫡
@nguyenhuy58033 жыл бұрын
thank you so much!
@yasmineahmedaboeleinin78446 ай бұрын
👍🏻👍🏻
@BendoubaAbdessalem3 ай бұрын
java is wierdly similar to c#, i know , it's the other way around but that code is wierdly fimiliar
@TianaPayetTravel10 ай бұрын
Helpful!
@TheEvertonDias Жыл бұрын
Thanks, Bro!
@thatnelfy2 жыл бұрын
good video! ty!
@alien_X13 жыл бұрын
Pls bring on hcking😊😊
@werq27 Жыл бұрын
brilliant👍
@sug_madic76833 жыл бұрын
Long time no see
@hamidrezaei35152 жыл бұрын
nice
@Onlinetraining-h7x5 ай бұрын
Is this program code similar to ArrayList internal code??
@MrLoser-ks2xn2 жыл бұрын
Thanks
@mariostheophanous23003 жыл бұрын
Can you make tutorial for mips assembly?
@ahmadyaseen26173 жыл бұрын
Please make some applications on javafx like you made for swing And after database please teach artificial intelligence
@Snowmanver22 жыл бұрын
Thanks!
@danielmilewski76592 жыл бұрын
thanks bro!
@zaisk7714 Жыл бұрын
When you do the insert method, why is the for loop: for (int i = size; i > index; i--) array[i] = array[i - 1]; rather than for (int i = size + 1; i > index; i--) array[i] = array[i - 1]; if you have an array = {A, B, C, D, null, null} size = 4 So the first for loop would set array[4] = array[3] which is saying the fourth element is equal to C. But what happens to D?
@gonkillua1001 Жыл бұрын
i starts at 0. array[4] = "null" since it's index 0, 1, 2, 3, 4 So array[4] = array[3] is correct as it is setting null to D, D to C...... n Hope that makes sense
@HandstandDad Жыл бұрын
yup and the size kind of is your pointer holding the space for the move to the right
@phlegmsmoothie Жыл бұрын
Why use a dynamic array in C++ when we can give int array[n]. Dynamic arrays are created when number of data items is unknown. But we could also use int n; cin>>n; int array[n];
@tasneemayham974 Жыл бұрын
I don't get how this code works... for(int i = 0; i
@xXMaDGaMeR2 жыл бұрын
amazing contnet
@A7X-Rev3 жыл бұрын
thx
@tonystark33993 жыл бұрын
Bro please make a series on kivy GUI with python 🙏🙏🙏
@harshitsharma67013 жыл бұрын
bro are your all in one vedios sufficent for start coding for the first time, i mean if i watch all of em
@satyamshankar26733 жыл бұрын
Bro i want to watch this playlisy but can u please tell me what are data structures and algorithm.
@Ankit-ge7yn3 жыл бұрын
Android developement tutorial please..🙏🙏
@MRIVAR3 жыл бұрын
Hyy bro make video on android development. I will appreciate that 💓
@emrehanhosver83793 жыл бұрын
guys its irrevelant but do you know how to scrap live data from web sites (stock, crypto) with c++
@shubhankarbera23 жыл бұрын
Is there any difference in all in one course and other which you gave made separately in same language ?
@BroCodez3 жыл бұрын
I compile all the lessons in the playlist into one video. I think the Java course only has 80 videos from the 100 playlist tho
@shubhankarbera23 жыл бұрын
@@BroCodez okk
@shubhankarbera23 жыл бұрын
@@BroCodez so for java I should refer to the playlist ?
@yehannk4483 жыл бұрын
bro in the toString() method you created without calling the method in the main class how did it be automatically called when you printed the dynamic array please reply
@justswift_12132 жыл бұрын
The .toString() method can be called both implicitly and explicitly. Calling this method is unnecessary as the java compiler automatically calls it on the array as it sees the code trying to print that array. Simply, it gets called automatically even if you don't call it explicitly. Hope it helps.
@aditya_asundi3 жыл бұрын
Hey bro, could you include the source code in C++ also? It would be great.
@m0lecules9 ай бұрын
🖖
@cartoonworld35763 жыл бұрын
Yaaa boi
@eugenezuev734928 күн бұрын
sweetest
@yeonve3 жыл бұрын
I want you to make a tutorial and how to make splash screen in mcp minecraft 1.8.8, if you didn’t do it’s okay! I just tryna find a tutorial how to make a splash screen in mcp minecraft 1.8.8
@yeonve3 жыл бұрын
💆♂️🧖♀️
@BroCodez3 жыл бұрын
I'm actually not familiar with Minecraft mods... at least not yet
@yeonve3 жыл бұрын
@@BroCodez hmm okay 😆
@COWHATE2 жыл бұрын
Hell yeah I was like 666 very cool.
@mmaScholar993 жыл бұрын
Hey man, I know you're busy and all, but I have a little coding problem I need help with.
@Heizo21 Жыл бұрын
random comment
@passwordprotectedd Жыл бұрын
7:54
@hardlycoding85442 ай бұрын
13.01
@mehdilee8 ай бұрын
So why did you get kicked out of heaven?
@Ankit-ge7yn3 жыл бұрын
Question = In java programming.. Int[ ] [ ] a= { {1,2,3}, {5,6,7}, {8,9,10} }; And I want to print , 1 5 8 2 6 9 3 7 10 (as a output) Sir How to print this output, please help ??
@edis98693 жыл бұрын
It's just like reading through regular 2D array but printout a[j][i] instead of a[i][j]. Hope it helps
@kenox12322 жыл бұрын
random comment for u my dude
@aleksandarmitrevski8391 Жыл бұрын
Random comment down below - checked
@khanhtang44513 жыл бұрын
no translate for me!! my E is bad so i can't understand what are u Saying
@BroCodez3 жыл бұрын
They should auto-translate, it might take a while to generate since this video is longer than usual
@khanhtang44513 жыл бұрын
@@BroCodez thanks, i very like your videos. I hope u will make videos. +1 respect 😂😂😂
@AR-rg2en Жыл бұрын
Random comment
@qaisnnn72643 жыл бұрын
😏
@yehannk4483 жыл бұрын
bro in the toString() method you created without calling the method in the main class how did it be automatically called when you printed the dynamic array please reply
@rectaalborween84716 ай бұрын
I might be a bit late lolol But to answer your question, this is because println() has an overloaded variant which calls "object.toString()" When we write the toString() body all we're actually doing is overloading that method