- 1
What happen?
if we remove the 4th line of the program where 42 is written then also output will be 4 than what is the difference inserting the line and not? and what that line indicates. kindly help.
6 Answers
+ 2
What's the program?
+ 2
The last line print the value of 'x' which was initialized in previous line with the value of element indiced [1][0] in the 'myArr' array...
The line you attempt to remove ( myArr[0][2]=42; ) assign a new value to element indiced [0][2] in 'myArr': this line of code don't change the value assigned to 'x' so it's ever output '4' ;)
+ 2
It isn't required for this output, but what's the context?
While we dont know it ( maybe you do, but you've posted only an extract or example without context ), we only can guess that line have arbitrary utility and by default, we must consider it's required for something ^^
0
public class Program {
public static void main(String[] args) {
int[ ][ ] myArr = { {1, 2, 3}, {4}, {5, 6, 7} };
myArr[0][2] = 42;
int x = myArr[1][0];
System.out.println(x);
}
}
0
I need to understand the basic of Java, JavaScript and PHP. I want to apply for a job overseas in Russia. and the job requires a candidate with engineering degree in computer science. but I am an engineer with electronics and communication engineering. that's why it's been a little difficult for me to understand. I really really need that job. I would be glad if you can help me understand, if u don't mind. thank you.
0
why it is required? without that the output will be same.



