#9 Arithmetic Operators in Java

preview_player
Показать описание
Check out our courses:

Coupon: TELUSKO10 (10% Discount)

Udemy Courses:

For More Queries WhatsApp or Call on : +919008963671

In this lecture we are discussing:
1)Assignment operator
a) = is used to assign a value to a variable
b) += is used to assign a value to a variable by adding it to the existing value
c) -= is used to assign a value to a variable by subtracting it from the existing value

-- there are many but in this lecture we discussing only some

e.g of =
int num1=11;
int num2=12;
int result = num1 + num2;
int result1=num1-num2;
int result2=num1*num2;
int result3=num1/num2;
e.g of +=
int num=1;
num +=1; = num = num+1;
num +=5; = num = num+5;

e.g of -=
int num2=2;
num -=1; num =num-1;
num -=5; num =num-5;

2)increment and decrement operator
-- there are two type of increment and decrement operator
a) pre
b) post

-- post increment and decrement operator
int num=1;
num++;
-- this operator is known as post increment operator

num--;
-- this operator is know as post decrement operator

-- pre increment and decrement operator
int num=2;
++num;

--num;

Difference between pre and post operator
e.g for that we take one example
int num=5;

int num1=5;

in post
first assignment and then increment
e.g int num=5; int copy;
copy=num++; in this case first num=5 assign to copy then increment the num
copy value is 5;

in pre
first increment then assignment
e.g int num=5;
int copy;
copy = ++num;

in this case first increment num value from 5 to 6 then assign to copy.
copy value is 6;

More Learning :

Donation:
PayPal Id : navinreddy20
Рекомендации по теме
Комментарии
Автор

Really sir you are great I complete 1 to 10 lecture in one day without any doubt thank you so much sir 🥺🙏

Gattugamerfacts
Автор

Sir, I am really grateful for your teachings ❤️❤️

nirongajanayake
Автор

note: when trying to assign a value or fetch a value, post-increment will behavior differently from pre-increment.

yitingchen
Автор

Best series for learning java, Thank you sir

sandunjayasekara
Автор

sir so num1 = num1 + 2; and num1 += 2; is the same thing?

kirubasathish
Автор

Why video name is Assignment Operator in Java? it should be Arithmatic Operators in Java

pzdyujo
Автор

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.

durgaraoponnuru
Автор

sir please dont say star say Asterisk so the students can get a new work thank you sir

yashjangid
Автор

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 ?

nishalsreekanta
Автор

What is the difference Between
public static void main(String a[]) <--- (a[])
&
public static void main(String args[]) <--- (args[])

sm
Автор

Was the title of this video not meant to be "Arithmetic Operators in Java" ?

alfredndlovu
Автор

when you increment the value it should print 8 but why it is printing 7.

vivekvardhan
Автор

Why he used double // slash can anyone explain me

Naveen_kumar
Автор

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

nandakishore
Автор

Too much videos uploaded at the same time

amitavaghosh