creating an object of the Random class could also be done here to do the job: Random random = new Random(); nums[ i ] [ j ] = random.nesxtInt(); // put the upper limit inside the nextInt bracket if you want an upper limit.
you should explain what static methods before explaining Math.random function, how a beginner will able to understand this? How you are able to call a function without creating its object
Why useing int m : n in enhanced for loop we already using n : nums so its possible to print n array its give the array of the elements? Do you agree that? Chief
@Telusko, The main array is 3 rows and one column right? I see there is only one column for main array which has 3 arrays. The four columns are of internal arrays right?
import java.util.Arrays; public class Main{ public static void main(String[] args) { int[][] nums = new int[3][4];
for (int i = 0; i < 3; i++) { for (int j = 0; j < 4; j++) { int random = (int)(Math.random() * 10);//type casting nums[i][j] = random; System.out.print(random + " ");//row limit } System.out.println();//line break } System.out.println();//For each format for (int[] num : nums) { System.out.println(Arrays.toString(num)); } System.out.println();//For each format for (int[] is : nums) { for (int is2 : is) { System.out.print(is2 + " "); } System.out.println(); } } }
Just simply assigned the value in row and column format where row represent the no of array and column represent the no of elements in the array . Just for example first array 0th element we have to write Array[0][0]=some value; Like wise that second array third element supposed the array size is of 3 Then the syntax will be Array[1][3]=some value;
Another way scanner class should be in a nested loop where outer loop represent the row no(no of array )and inner loop represent the column (no of elements in the array) . The syntax will be:- Arr[row][column]=sc.nextInt();//before that you should include the scanner class in your code and create an object of that .
Yes, scanner class should be in a nested loop where outer loop represent the row no(no of array )and inner loop represent the column (no of elements in the array) . The syntax will be:- Arr[row][column]=sc.nextInt();//before that you should include the scanner class in your code and create an object of that .
Sir you teach every concept in an Amazing way. It is helping me to understand everything. Thanks a lot sir 🙏😊
You’re such an angel! You helped me so much in understanding my homework.
ayoo ayoo
Big fan of u Navin sir … fantastic series of java … like u had for python
You helped me a lot with my homeworks sir, thank you from Myanmar
creating an object of the Random class could also be done here to do the job:
Random random = new Random();
nums[ i ] [ j ] = random.nesxtInt(); // put the upper limit inside the nextInt bracket if you want an upper limit.
Normal for loop is better and clear than enhancled for loop
Yes
Nah enhanced for loop is much better you just have to understand that in enhanced for loop : iterates over a element in group
Thank you for this lesson, I have enjoyed it a lot, reminds me of my time in university with C++.
The best explanation ever! Thank you very much.
you should explain what static methods before explaining Math.random function, how a beginner will able to understand this? How you are able to call a function without creating its object
yes exactly not understood
What program do you use to draw the diagrams for us? I really like it
Why useing int m : n in enhanced for loop we already using n : nums so its possible to print n array its give the array of the elements? Do you agree that? Chief
@Telusko, The main array is 3 rows and one column right? I see there is only one column for main array which has 3 arrays. The four columns are of internal arrays right?
Yes, I do as you said after watching.
I think this topic is less used in daliy life purposes
Awesome tutorial!
Nice teaching nallave puriyuthu bro❣️
Sir that's best
Collection of lectures
Plz share
Assimignment or H. W
It's easy way to students understand and do H. W
Finally I found tamil comment❤
I run array in vs code it gives something main error. But I run in Eclipse it gives output.
broo navin bro thandani thane thane thandane thane thane noo brooo super explanation
What's about if we want to take input from the user?
Math.random not working in my compiler.why??
First u have to import it's library
You have to import it bro
@@nikilkandula8562 how can i import math library in vs codde.....can u please help me
@@lohithareddy15 type this code in the first line ok. " import java.lang.Math; ". 😊
@@lohithareddy15import java.util.Random;
Why don't we do this: Random rand = new Random();
import java.util.Random;
class Main
{
public static void main(String[] args)
{
Random rand = new Random();
int[][] arr = new int[5][];
for(int i = 0; i < arr.length; ++i)
{
arr[i] = new int[rand.nextInt(5,10)];
for (int j = 0; j < arr[i].length; ++j)
{
arr[i][j] = rand.nextInt(0,10);
}
}
for(int i = 0; i < arr.length; ++i)
{
for (int j = 0; j < arr[i].length; ++j)
{
System.out.print(arr[i][j] + " ");
}
System.out.println();
}
}
}
😂
sir why to take random Values teach and insert user given values.
import java.util.Arrays;
public class Main{
public static void main(String[] args) {
int[][] nums = new int[3][4];
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 4; j++) {
int random = (int)(Math.random() * 10);//type casting
nums[i][j] = random;
System.out.print(random + " ");//row limit
}
System.out.println();//line break
}
System.out.println();//For each format
for (int[] num : nums) {
System.out.println(Arrays.toString(num));
}
System.out.println();//For each format
for (int[] is : nums) {
for (int is2 : is) {
System.out.print(is2 + " ");
}
System.out.println();
}
}
}
How can we ourself initialize the multidimensional array as we do in 1d array
Just simply assigned the value in row and column format where row represent the no of array and column represent the no of elements in the array .
Just for example first array 0th element we have to write
Array[0][0]=some value;
Like wise that second array third element supposed the array size is of 3
Then the syntax will be
Array[1][3]=some value;
Another way
scanner class should be in a nested loop where outer loop represent the row no(no of array )and inner loop represent the column (no of elements in the array) .
The syntax will be:-
Arr[row][column]=sc.nextInt();//before that you should include the scanner class in your code and create an object of that .
Sir pls give free coupon code for your Udemy course. It's an amazing course and your explanation it just excellent
Sir can we scanner class to intialise variables
Yes, scanner class should be in a nested loop where outer loop represent the row no(no of array )and inner loop represent the column (no of elements in the array) .
The syntax will be:-
Arr[row][column]=sc.nextInt();//before that you should include the scanner class in your code and create an object of that .
Who don't have laptop or desktop
And practice with mobile
Lol 😂😂😂😂
Well my father will buy me one this diwali.. what about you did you finish java ?
if you are here then i would have kissed on your head man, you just clarified all the doubts which was there from ages ..
после активации бота, подскажите, как можно включить текущую сетку? не могу что то найти кнопку
I had a doubt, while typing it in the comments, it was solved 🤣🤣🤣
kuj smj ni andi