Posts

Recent posts

16 Java Fundamentals | Multidimensional Arrays in Java | By Dummy for Dummies

Java Multidimensional Arrays | Hassan Bukhari Java Notes 16 Java Fundamentals | Multidimensional Arrays in Java | By Dummy for Dummies Java Beginner Guide 2D Arrays Matrices Nested Loops INTRODUCTION Hey guys welcome back! Remember we made variable of variables? And called it Arrays? Today we are gonna talk about how we can even make Array of Arrays; they are called multidimensional Arrays. Think of a 2D array as an array that contains arrays: 2D Array → Contains Arrays → Contains variables/data 3D Array → Contains 2D Arrays → Contains Arrays → Contains variables/data And so on... 2D ARRAYS Imagine a classroom full of chairs. It does not contain a single line of chairs (1D Array) but rather rows and columns of chairs. Where: Row = Line of chairs Column = Specific chair in that row So to point to a specific chair you'd...

15 Java Fundamentals | Arrays in Java | By Dummy for Dummies

Java Arrays | Hassan Bukhari Java Notes 15 Java Fundamentals | Arrays in Java | By Dummy for Dummies Java Beginner Guide Arrays Indexing Collections INTRODUCTION Imagine you have money, you put the money in a wallet. It is like putting data in a variable. Now if you have a lot of wallets (definitely not stolen), and you put them all in a bag. That will be like putting all variables in another variable. That is exactly what Arrays are, variable of variables. ARRAYS In an array, all the data you store must have the same datatype. Here is the magical spell to create an array: int[] numbers = new int[5]; Let's break down the Java spell into our human language: int → It tells the program about the datatype of the array we want to create. Just like we did in making simple variables. [] → It tells the program that the datatype is actually ...

14 Java Fundamentals | Recursion in Java | By Dummy for Dummies

Java Recursion | Hassan Bukhari Java Notes 14 Java Fundamentals | Recursion in Java | By Dummy for Dummies Java Beginner Guide Recursion Self-Call Base Case INTRODUCTION Imagine you want to make a method that has to do a complex task which cannot be done in a single call. In that case, you can break the task into smaller parts: the method will do a small portion, then call itself again to handle the next part, and so on, until the desired result is reached. RECURSION A recursive method is more like a loop. It will call itself and repeat the same process. We will manually set some conditions for when to stop this whole process, and what to pass as arguments when the method calls itself again. Base Case Base case is the most important part of a recursive method. It is the condition which will decide when to stop the process. Without this, the recursive method will keep ...

13 Java Fundamentals | Overloaded Methods in Java | By Dummy for Dummies

Java Method Overloading | Hassan Bukhari Java Notes 13 Java Fundamentals | Overloaded Methods in Java | By Dummy for Dummies Java Beginner Guide Overloading Methods Polymorphism INTRODUCTION It is not necessary that different methods must have different names. Methods are actually recognized by signature rather than just name. The signature of a method includes the name of the method and its parameters in which they receive arguments. So you can have methods with the same names, yet they will receive different arguments and perform different functions. METHOD OVERLOADING Imagine the boss monkey sometimes needs to add 2 numbers, while sometimes it needs to add 3 numbers. But the different number of arguments passed cannot be received by the same method. In that case, you can create another method with the same name and set it to receive the desired number of arguments. As ...

12 Java Fundamentals | Methods in Java | By Dummy for Dummies

Java Methods | Hassan Bukhari Java Notes 12 Java Fundamentals | Methods in Java | By Dummy for Dummies Java Beginner Guide Methods Functions Reusability INTRODUCTION What if I tell you, you can have an assistant in your program that will do a specific task assigned to it every time you ask. Every time you call the assistant, give it the data, it will do the assigned task. All you have to do is just code it for once, and then call it unlimited times to do your tasks. METHODS In Java, a method is a block of code enclosed in curly brackets. There is a main method always, and you can create multiple other methods if you want. Think of these like you have one boss method and many assistants. Boss Method → Always executes, code execution starts from here. Assistant Methods → You can choose to execute them multiple times, or not even once; depends on you, executes ...