Why doesn't type promotion does work in case of int and long? for ex - int x = 2^31-1; int y = 2^31-1; long z = x+y; System.out.println(z); gives -2 and not 2^32-2. (please note '2^x' notations are just for understanding and not actually used in the code)
When we do num1++ or some other operations, values are being changed in output. Again when we perform another operation, its being performed on default number, instead of updated value. Can anyone explain this. For eg: num1=7; when num1++ is performed, value changed to 8, Again when another operation say num1 +=1; is performed value still showing 8 instead of 9.
See There is two option first is to use looping statement(For loop, while loop) For Example: class HelloWorld { public static void main (String[] args) { int num1=1; while(num1
4:18 the output must have been 7 right? Because num1 is assigned with 9 after increment? 9 - 2 = 7. But how was the output 5 and even in multiplication it took 7 * 8 and not 5 * 8. Can someone explain this ?
It was commented out with double slash after it was made to 9. So now num 1 will be with its original value and will remain as 7. Now when num1 -= 2 is coded, it will result in output as 5. The same goes with multiplication since now original value of num1 remains 7 and when the line num1 *=8 it's num 1= num1(which is 7) *8 = 56
@@Ilamaran-n9fit's called a command which is used to ignore that line which basically means the compiler ignores that line from compiling we can use it by ctrl+l in vscode
public class confus { public static void main (String args[]) { int num = 7; int a = ++num; int b = num++; System.out.println(a); System.out.println(b); }
} this program getting output as 8 8 instead 8 7 any explanation please
bro im not sure wt u r asking but, the post n pre increment does the same job but differently...like said in the video. ++num n num++ will give the same output for 7. As we know if we give our intial value e.g num=9, we get 10 either if we give ++num or num++ but ur class name😹
So the reason why b is giving result as 8 is when a= ++num is executed value of num changes to 8 and so b fetches the last updated value of num which is 8 and prints it and then increments it to 9. Now when a=++num is executed a will be printed as 10 and b as 10 and then a as 11 and b as 11 and so on. Basically value of num changes even though you assign that to a separate variable like a or b.
Really sir you are great I complete 1 to 10 lecture in one day without any doubt thank you so much sir 🥺🙏
dude has 1.25x speed by default
Still i am watching him in 1.5×
Yeah bro
😂😂😂😂
Yes me to watching at speet 1.5x
Me watching at 1.75x
Sir, I am really grateful for your teachings ❤️❤️
Best series for learning java, Thank you sir
sir so num1 = num1 + 2; and num1 += 2; is the same thing?
Yes, num1 +=2 internally works as num1=num1+2
yes both are same
note: when trying to assign a value or fetch a value, post-increment will behavior differently from pre-increment.
Why doesn't type promotion does work in case of int and long? for ex - int x = 2^31-1; int y = 2^31-1; long z = x+y; System.out.println(z); gives -2 and not 2^32-2. (please note '2^x' notations are just for understanding and not actually used in the code)
best tutorial ever
Why video name is Assignment Operator in Java? it should be Arithmatic Operators in Java
When we do num1++ or some other operations, values are being changed in output. Again when we perform another operation, its being performed on default number, instead of updated value. Can anyone explain this.
For eg: num1=7;
when num1++ is performed, value changed to 8,
Again when another operation say num1 +=1; is performed value still showing 8 instead of 9.
Because you are giving num1=7 at start of code everytime you run
See There is two option first is to use looping statement(For loop, while loop) For Example:
class HelloWorld {
public static void main (String[] args) {
int num1=1;
while(num1
What is the difference Between
public static void main(String a[])
Just a name difference, just like you can give variable any name
No difference, bro. You can put any name there a[], args[], sampath[], anything.
Thanks guys
no difference both are name suppose u use args than u can use a in any other operation which will make it easy to understand
4:18 the output must have been 7 right? Because num1 is assigned with 9 after increment? 9 - 2 = 7. But how was the output 5 and even in multiplication it took 7 * 8 and not 5 * 8. Can someone explain this ?
It was commented out with double slash after it was made to 9. So now num 1 will be with its original value and will remain as 7. Now when
num1 -= 2 is coded, it will result in output as 5. The same goes with multiplication since now original value of num1 remains 7 and when the line num1 *=8 it's num 1= num1(which is 7) *8 = 56
sir please dont say star say Asterisk so the students can get a new work thank you sir
very much help ful
Sir you did really great :)
thank you
Was the title of this video not meant to be "Arithmetic Operators in Java" ?
Tq sir😊😊
i just realized u were using macOS
yovvvvv this is arithmetic operator yarrrrr
How to find percentage sirr😅😅
9:56
when you increment the value it should print 8 but why it is printing 7.
Bcz we insert is this to system. Out. Println() ;
// we insert than number it is perform value & condition & Inc/dec
Ex:
For(int vivek =1;vivek
@@hari3245 So 1st the given value is going to print and then it will perform other condition right.
@@vivekvardhan6491 yeah..
Why he used double // slash can anyone explain me
it is used to make that line a comment which will be ignored by java while running
// for what purpose he was using this !!!
in the literal series also he didn't explain about it😔
Coz to ignore the title he used before , just the way rest all ignore ur comment dumbo
@@Ilamaran-n9fit's called a command which is used to ignore that line which basically means the compiler ignores that line from compiling we can use it by ctrl+l in vscode
@@IAmSharadhNaidu thx bro
public class confus
{
public static void main (String args[])
{
int num = 7;
int a = ++num;
int b = num++;
System.out.println(a);
System.out.println(b);
}
}
this program getting output as 8
8
instead 8
7
any explanation please
bro im not sure wt u r asking but, the post n pre increment does the same job but differently...like said in the video.
++num n num++ will give the same output for 7.
As we know if we give our intial value e.g num=9, we get 10 either if we give ++num or num++
but ur class name😹
So the reason why b is giving result as 8 is when a= ++num is executed value of num changes to 8 and so b fetches the last updated value of num which is 8 and prints it and then increments it to 9. Now when a=++num is executed a will be printed as 10 and b as 10 and then a as 11 and b as 11 and so on. Basically value of num changes even though you assign that to a separate variable like a or b.
Too much videos uploaded at the same time