Write the difference between a == 5 and a = 5 b)Write a program in JAVA to input principle, rate and time. Calculate the simple interest & print the result with appropriate messages. NOTE : Simple interest = (Principle x Rate x Time) / 100 *
5 points
Add File
Answers
Answer:
a==5 is used in computer language but... a=5 is used by us.... (both have same value)
Answer:
a=5 this format is only used when you have to declare variables.
and
a==5 is used in if else statements and so on...
a==5 means a is equal to five then it can be string or integer data type but if there's a===5 then it means a is equal to five and they both lies in same data type.
eg.
a is equal to 5 ( in int) is defined but if you put
if(a == '5'){ return a}
then it will give true
but
if you put
if(a=== '5'){ return a}
this time it will give false because a is defined as 5 but it was in integer data but now you are checking it in string data type
so,
overall == is used to check values only whereas, === is used to same data types also.
Hope it helps...