Java Tutorial: Associativity of Operators in Java

CodeWithHarry
8 Sept 202017:52

Summary

TLDRThis video covers essential topics related to operator precedence and associativity in Java, explaining how Java evaluates expressions. The speaker clarifies that, unlike mathematical BODMAS rules, Java relies on precedence (which operator is applied first) and associativity (the direction of execution). Through examples, they demonstrate how operators like multiplication, division, addition, and subtraction are evaluated in different contexts, helping viewers understand complex expressions. The video is highly relevant for students, interviewees, and anyone preparing for exams, offering a deep dive into an often misunderstood topic.

Takeaways

  • 💻 The video focuses on explaining operator precedence and associativity in Java.
  • 🔢 Java does not use the BODMAS rule, but instead follows precedence and associativity rules for operator evaluation.
  • 🛠️ Operators like multiplication (*) and division (/) have higher precedence than addition (+) and subtraction (-).
  • ⚖️ Associativity determines the order in which operators with the same precedence are evaluated (left to right or right to left).
  • 📊 In Java, multiplication and division operators are left-associative, meaning they are evaluated from left to right.
  • 🧮 Example: The expression '60 / 5 - 34 * 2' evaluates division first (60/5=12), then multiplication, and finally subtraction, resulting in -56.
  • 📃 The instructor emphasizes using parentheses to avoid errors in complex expressions where multiple operators are involved.
  • 🎓 The video includes a quadratic expression example, showing how operator precedence affects evaluation and how to correct it using parentheses.
  • 📈 Operator precedence is critical in programming, especially during interviews or exams, as it affects how expressions are executed.
  • ✅ The video encourages viewers to understand these concepts early on to avoid common mistakes in programming and interviews.

Q & A

  • What is operator precedence in Java?

    -Operator precedence in Java determines the order in which operators are evaluated in expressions. Operators with higher precedence are evaluated before those with lower precedence.

  • How does associativity affect the evaluation of expressions?

    -Associativity defines the direction in which operators with the same precedence are evaluated. Most operators in Java are left-to-right associative, meaning they are evaluated from left to right.

  • What is the difference between precedence and associativity?

    -Precedence determines which operator is evaluated first based on priority, while associativity resolves the order of evaluation for operators with the same precedence, dictating whether they are evaluated from left to right or right to left.

  • Why is the rule of BODMAS not used in Java?

    -Java uses precedence and associativity rules instead of the BODMAS rule for evaluating mathematical expressions. The precedence of operators in Java is defined by the language, not mathematical conventions like BODMAS.

  • How does Java evaluate the expression `6 * 5 - 34 / 2`?

    -In Java, `6 * 5` is evaluated first because multiplication has a higher precedence than subtraction. Then, `34 / 2` is evaluated because division also has higher precedence than subtraction. Finally, `30 - 17` is calculated, resulting in 13.

  • What happens when operators have the same precedence?

    -When operators have the same precedence, associativity determines the order of evaluation. For example, both division and multiplication have the same precedence, so Java evaluates them left to right.

  • How can parentheses change the order of evaluation?

    -Parentheses override the default precedence and associativity rules, forcing specific parts of an expression to be evaluated first. For example, `(6 - 5) * 2` will evaluate the subtraction before the multiplication, even though multiplication has higher precedence.

  • What happens if the denominator of an expression becomes zero?

    -If the denominator of an expression becomes zero, Java will throw an `ArithmeticException`, indicating a division by zero error. Division by zero is undefined in mathematics and causes an error in programming.

  • What is the significance of knowing precedence and associativity for interviews or exams?

    -Understanding operator precedence and associativity is crucial for writing and debugging Java code. It also helps in solving coding questions in interviews and exams where correct expression evaluation is necessary.

  • Why is it important to use parentheses in complex expressions?

    -Parentheses help clarify the intended order of evaluation in complex expressions, preventing unexpected results due to precedence and associativity rules. This makes code more readable and less prone to errors.

Outlines

00:00

🔧 Understanding Java Operator Precedence

The first paragraph introduces the topic of operator precedence in Java, which is important both in academic contexts and technical interviews. It explains that operators are applied and evaluated based on their precedence, and the video aims to cover this concept thoroughly. The speaker starts by naming the Java file and demonstrating an example of how precedence works in a Java expression. They highlight that precedence determines which operations are performed first, such as multiplication or division over addition or subtraction, and clarify that Java uses precedence and associativity rules instead of the traditional BODMAS rule.

05:01

🔄 Associativity in Java Operations

This paragraph expands on the concept of associativity, particularly how it resolves conflicts when operators have equal precedence, such as multiplication and division. Associativity determines the direction in which operations are evaluated—left-to-right or right-to-left. The speaker provides a practical example involving division and subtraction, and walks through how associativity impacts the final result. They stress that many students mistakenly apply the BODMAS rule, but in Java, associativity is key to determining the order of operations.

10:01

📝 Practical Example: Operator Precedence and Associativity in Expressions

The third paragraph introduces a 'quick quiz' for the audience, focusing on how to correctly write expressions based on the discussed concepts. The speaker gives examples of algebraic expressions like quadratic equations and walks through how to code them in Java, emphasizing the importance of precedence and associativity in getting the correct result. They also explain why using parentheses is recommended for complex expressions to avoid unintended evaluation orders, providing a detailed breakdown of how expressions like 'b² - 4ac / 2a' are evaluated in Java.

15:01

📊 Highest Precedence: The Role of Parentheses in Complex Expressions

In this paragraph, the speaker explains that parentheses have the highest precedence, meaning that any expression inside parentheses is evaluated first. They use this concept to further clarify how complex expressions, like those involving quadratic equations, should be handled in Java. The speaker also provides a mathematical rule that division by zero leads to undefined expressions, which can cause errors in programming. They conclude by encouraging viewers to understand these concepts early to avoid struggles during exams or interviews.

👍 Wrapping Up and Final Thoughts

The final paragraph provides a conclusion, summarizing the key points discussed in the video—operator precedence, associativity, and how to correctly evaluate expressions in Java. The speaker reflects on their personal experience of learning these concepts later in their career and emphasizes the importance of mastering them early. They also invite viewers to like the video, share it on social media, and stay tuned for future content. The speaker signs off by thanking the audience for watching.

Mindmap

Keywords

💡Operator Precedence

Operator precedence refers to the rules that determine the order in which different operations are evaluated in an expression. In the video, the speaker explains how operators like multiplication and division have higher precedence than addition and subtraction, meaning they are evaluated first. For example, in the expression `6 * 5 - 34 / 2`, multiplication and division are evaluated before subtraction.

💡Associativity

Associativity defines the direction in which operations of the same precedence level are evaluated. In Java, some operators are left-associative (evaluated from left to right), while others are right-associative. For example, multiplication and division share the same precedence, but are evaluated left to right when they appear together, such as in `60 / 5 * 2`, where division happens first.

💡BODMAS

BODMAS (Brackets, Orders, Division, Multiplication, Addition, Subtraction) is a mathematical rule for the order of operations. However, the video emphasizes that Java does not strictly follow BODMAS but rather relies on operator precedence and associativity. This distinction is crucial for understanding how Java evaluates expressions differently than pure mathematical notation.

💡Expression

An expression in Java consists of operators and operands that are evaluated to produce a value. The speaker uses various examples like `int a = 6 * 5 - 34 / 2` to explain how expressions are evaluated based on precedence and associativity, showing how to correctly interpret the result using Java’s rules rather than mathematical intuition.

💡Multiplication and Division

Multiplication and division are two arithmetic operators that have higher precedence over addition and subtraction. In the video, the speaker uses the example `6 * 5 - 34 / 2` to show that these operations are performed first. Both operators share the same precedence but are left-associative, meaning they are evaluated from left to right when together in an expression.

💡Addition and Subtraction

Addition and subtraction are arithmetic operators that have lower precedence than multiplication and division. In the expression `6 * 5 - 34 / 2`, subtraction occurs after both multiplication and division are completed. The video highlights that the lower precedence of these operators impacts the final result of an expression.

💡Quadratic Formula

The quadratic formula `b^2 - 4ac / 2a` is used to solve quadratic equations. The speaker uses this as an example to demonstrate the importance of using parentheses to ensure the correct order of operations when writing expressions in Java. Without proper parentheses, the formula could yield incorrect results due to operator precedence and associativity.

💡Parentheses

Parentheses are used to override the default precedence and associativity rules in expressions. The speaker emphasizes their importance when dealing with complex expressions like the quadratic formula, ensuring that operations happen in the desired order. For example, placing parentheses around `b^2 - 4ac` ensures that this part of the expression is evaluated before dividing by `2a`.

💡Arithmetic Exception

An arithmetic exception occurs when an illegal arithmetic operation, such as division by zero, takes place. The speaker warns about the risk of encountering such an exception when the denominator in a division operation becomes zero, such as in the expression `b^2 - 4ac / 2a` when `a` is zero, leading to undefined behavior in programming.

💡Interview and Exam Preparation

The video repeatedly mentions that understanding operator precedence and associativity is crucial for success in academic exams and technical interviews. The speaker reflects on how mastering these concepts late in his career made him realize their importance, and now he wants to make them accessible early on for viewers preparing for Java-related assessments.

Highlights

Introduction to Java operator precedence and associativity, essential for both academic exams and job interviews.

Explanation of operator precedence: multiplication and division have higher precedence than addition and subtraction.

Example using the expression 'int a = 6 * 5 - 8 / 2', explaining how precedence leads to evaluating multiplication and division before addition and subtraction.

Clarification that Java does not follow the BODMAS rule but instead uses operator precedence and associativity.

Definition of associativity: when two operators have the same precedence, associativity (either left-to-right or right-to-left) determines the evaluation order.

Demonstration of left-to-right associativity using division and multiplication in an expression like '60 / 5 - 34 * 2'.

Difference between associativity of star (multiplication) and slash (division): both have equal precedence but are evaluated left-to-right.

Practical example: how left-to-right associativity in Java affects the result of a complex expression like '60 / 5 - 34 * 2'.

Use of comments in code to clarify which operations will be evaluated first based on precedence and associativity.

Explaining how parentheses can override default precedence and associativity in Java expressions.

Quadratic equation example: 'b^2 - 4ac / 2a', showcasing how operator precedence and parentheses affect expression evaluation.

Recommendation to use parentheses in complex expressions to ensure correct evaluation order and avoid programming errors.

Mention of potential programming errors, like arithmetic exceptions when the denominator becomes zero in division.

Personal note: the speaker reflects on their own late understanding of these concepts during their career, emphasizing the importance of learning early.

Encouragement to share and like the video, inviting viewers to tag the speaker on Instagram when sharing screenshots.

Transcripts

play00:00

Guys, today's video will cover some important topics

play00:02

like which thing is done first

play00:04

Java compiler multiply will do first

play00:06

divide will do first or then

play00:08

subtract will do first or addition will do first

play00:10

what is the precedence of our operator

play00:13

what is the associativity of our operator

play00:16

many questions are asked on these topics

play00:19

whether you are from academics or

play00:21

you are giving an interview for a corporate

play00:23

this video is going to be very important for you

play00:26

so in today's video we are going to discuss this thing

play00:33

guys in this course of java we have talked a lot

play00:35

in today's video we will talk about how precedence works of operator

play00:40

because we have seen operators, types of operators

play00:43

how expressions are there, we can write in java we have seen the types of operators what are the expressions we can write in java

play00:46

we have seen all these things in detail

play00:49

and you must have understood it well, we have done a lot of work on this

play00:52

but I will do one thing here that I will make a file

play00:55

and I am going to keep its name

play00:58

I will keep its name according to the video number

play01:01

so that whenever you are watching the video number, you will know which file it is

play01:04

I have to give you a code, so I write here its name

play01:07

09 underscore

play01:10

and here I write cwh underscore

play01:13

and chapter 2

play01:16

operator precedence dot java

play01:20

ok

play01:20

and what is this problem, I think I have done something wrong, I can't write 09 in this

play01:26

this is the problem, my class name can't start with 09

play01:29

no problem, I will write cwh underscore 09

play01:32

and see here, this is my class

play01:35

I will minimize it, zoom in a little

play01:38

let's put the main function here and we are good to go now

play01:41

we can do our coding here

play01:44

so I have told you about precedence in notes

play01:46

precedence of operators

play01:48

the operators are applied and evaluated based on precedence

play01:51

so here according to precedence

play01:54

your operators are applied like

play01:57

less precedence of plus and minus than star divide

play02:00

let's say i write an expression here

play02:03

int a is equal to 6 multiplied by 5 minus a divided by 4

play02:07

or 2 let us say

play02:09

I do it like this and I shout it

play02:12

I say print this

play02:14

if you apply the rule of baud mass

play02:16

apply the rule of baud mass, if the rule of mathematics is

play02:19

6 multiplied by 5 will be 30

play02:21

and 34 divided by 2 will be 17

play02:23

so here 30-17 is 13

play02:26

so this 13 will be the answer

play02:29

you can see here I have run the wrong file

play02:32

I have to right click and see here 13 is here

play02:35

but what happens is that in java, baud mass is not used

play02:38

in java, precedence and associativity is used

play02:41

so what are these two things

play02:43

today I will explain you well precedence and associativity so what are these two things today I will explain you

play02:46

precedence and associativity

play02:48

what is precedence?

play02:50

precedence means

play02:52

that I am bigger than you

play02:54

so star means minus

play02:56

that I am bigger than you

play02:58

and minus means

play03:00

that I am bigger than you

play03:02

and the bigger one

play03:04

is evaluated first the other will be evaluated first

play03:05

the one who is bigger will be evaluated first

play03:09

the one who is the most respected person will be evaluated first

play03:15

and then the slash will be evaluated

play03:20

now see why is this happening here

play03:23

what is the precedence of associativity

play03:26

the precedence is that star is bigger than minus

play03:29

so it will be evaluated first

play03:32

but what is associativity

play03:35

and to explain associativity i will write an expression b

play03:38

in which i will do a simple thing, i will put a slash and put a star

play03:41

ok

play03:43

ok i will tell you one thing

play03:45

now tell me in which order it will be evaluated

play03:47

earlier it was 6x5

play03:49

then 34x2

play03:51

and then this result and this result

play03:54

but now we have to see its evaluation order

play03:57

this is associativity

play04:00

if your star is big

play04:02

then it will be evaluated like this

play04:04

let me put a comment here, multiline, and look at this carefully

play04:07

you will not know this thing by chance

play04:10

6 multiplied by 5 will be 30

play04:13

minus then it will be 34 divided by 2

play04:16

and after that it will be evaluated as 30 minus 17

play04:21

and it will be equal to 13 this was our precedence but if I do the same thing for you

play04:30

I do the same thing for B then you will see that what you think will not happen

play04:34

there is a high chance that it will not happen

play04:36

now there is a difference between star and slash

play04:39

which one will be evaluated first

play04:41

some people will say put a bodmask and do star

play04:46

divide first and then multiply

play04:49

no it doesn't work like that

play04:52

here bodmask doesn't work

play04:55

here we see associativity

play04:58

so precedence is equal to slash and star

play05:01

now when precedence is equal

play05:04

star and slash are equal in precedence

play05:07

so to break this tie we see associativity

play05:10

associativity is like this, left to right, right to left

play05:13

associativity of star and slash is left to right

play05:19

so it will start to get evaluated like this

play05:22

so 6 divided by 5 will be first

play05:24

and I will make it 60

play05:26

so that the expression will be correct

play05:28

60 divided by 5 will be 12

play05:30

and I will remove the rest of the expression

play05:32

then you can see here

play05:34

34 multiplied by 2 will be here

play05:36

which is 68

play05:38

so 12 minus 68 will be

play05:40

and 12 minus 68 is

play05:42

12 minus 68

play05:44

is minus 56 so is equal to minus 56

play05:46

so it will be minus 56

play05:48

so let's print B

play05:49

and let's print B here

play05:52

I will run it here and see minus 56 is here

play05:57

so 13 was here and minus 56 is here

play06:01

so this is how our associativity works

play06:04

so minus 56 minus 56 and 13

play06:07

now many of you will think that how will we get associativity and how will we know

play06:12

that what is the thing that we multiply first and divide

play06:16

so to make this thing easy I have prepared an image for you

play06:20

see here all the precedence, associativity

play06:26

of all operators are written here

play06:29

now many of you may not know about these operators

play06:32

and you don't need to know about it, you just need to keep this list

play06:35

you don't need to keep it, you just need to refer this table

play06:38

whenever you will evaluate operators

play06:41

then first of all you will see

play06:44

who has the highest precedence here

play06:46

this number is given to the precedence, highest precedence

play06:49

so here if I want to see

play06:52

which one will be evaluated first, let me zoom in

play06:55

so in plus and star, you see here

play06:58

the precedence of plus is less, the precedence of star is more

play07:01

star has 12 precedence, plus minus has 11

play07:04

so I will evaluate star first

play07:06

but if star and slash come together

play07:09

if I face both of them together

play07:11

then I will use associativity

play07:13

I will evaluate left to right

play07:15

if there is slash in left then it will be evaluated first

play07:18

if there is star then it will be evaluated first

play07:20

like if I show you this expression

play07:23

here 60 by 5 minus 34 into 2

play07:25

so here slash is not being divided because the bodmass rule is running

play07:29

that's why it is being evaluated first because it is in the left

play07:33

associativity goes from left to right

play07:36

this way your order of evaluation works

play07:39

if you have a tie in the operators, if there is a tie in the precedence

play07:43

so first of all associativity to break the precedence and tie, associativity is fine

play07:48

so precedence and associativity work like this

play07:52

so here I write, I make the comment very clear

play07:55

that here, see, this star and slash, star was evaluated first

play08:01

because its highest precedence of star and slash

play08:05

and after that associativity was left to right

play08:08

highest precedence goes to star and slash

play08:17

they are then evaluated on the basis of left to right associativity

play08:28

left to right associativity

play08:32

after that they are getting evaluated

play08:35

so they will get evaluated on the basis of left to right associativity

play08:39

so here A's value is this B's value is this

play08:42

and they are getting evaluated very easily

play08:45

so I have written the same thing in notes for you

play08:48

precedence of operators, operators are applied and evaluated based on precedence

play08:51

ok, they are evaluated based on precedence

play08:54

I have taken an example, there is less precedence of plus and minus

play08:57

star and slash, so star and slash are evaluated first

play09:00

and many students don't know that

play09:02

that evaluation is done according to precedence and associativity

play09:04

some people start applying baud mass here and say it is evaluated according to the precedence and associativity

play09:06

some people start using the word board mask

play09:09

and say that it is based on the board mask

play09:12

some people say that it is a dangerous thing and we don't want to learn it

play09:15

it is not dangerous, it is just an image

play09:18

you have to look at the image carefully

play09:21

and understand it

play09:24

and this image will tell you

play09:25

that what is the precedence of what and what is associativity

play09:29

so here you have seen what is precedence and what is associativity

play09:35

after that you can evaluate your expression

play09:37

so here it is written about associativity that tells the direction of execution of operators

play09:41

it can either be left to right or right to left ok

play09:45

star slash is left to right

play09:47

plus minus is left to right

play09:49

plus plus right to left

play09:50

plus plus or equal to right to left

play09:52

like if you write something like this

play09:54

a is equal to b is equal to c

play09:58

equal to 45

play09:59

so first b value will be 45

play10:01

then a value will be equal to it

play10:03

means it runs like this right to left

play10:05

so it is not necessary that you have left to right

play10:08

or associatively right to left

play10:10

now here is a quick quiz for you

play10:12

that how will you write these expressions

play10:14

the expressions which I have written

play10:16

on the basis of these concepts how will you write

play10:19

so here x-y divided by 2

play10:21

b square minus 4ac by 2

play10:23

b square minus u square, a star b minus t

play10:26

so if I want to write these expressions, I will write it here

play10:30

quick quiz

play10:32

so

play10:34

here what I will do is

play10:38

I will write this first

play10:41

a x minus y by 2

play10:43

so if I write x star Y by 2 here

play10:47

suppose I wrote int k is equal to

play10:50

and I will comment out all these above

play10:52

because I don't want to disturb us

play10:55

when we are coding below

play10:57

so I will do this whole precedence associativity

play11:00

this is a topic

play11:01

I am commenting this topic completely

play11:05

and you guys focus down, so I have put it here like this

play11:12

no problem, no problem, here this comment is actually getting closed

play11:17

so there is a problem, no problem, I will do it like this

play11:20

I will comment it like this, you guys have understood

play11:22

I have just explained it to you, so I have done k is it to you so k is equal to x

play11:26

x into y is equal to 2

play11:28

so if i do int x is equal to 5

play11:30

int y is equal to 1

play11:32

so what will be the value of this

play11:34

5 multiplied by 1 is 5

play11:36

and 5 divided by 2

play11:38

let's make it 6

play11:40

6 multiplied by 1 is 6

play11:42

and divided by 2 is 3

play11:44

so if i write it like this and 6 multiply by 1 will be 6 and divided by 2 will be 3

play11:45

so if i write it like this

play11:48

and system.out.printlnk

play11:51

so what will be evaluated first

play11:54

so it will be evaluated first and then divided by 2

play11:57

so i don't have any risk of getting evaluated before y by 2

play12:00

so i will write it like this

play12:03

if i run it then I should get 3

play12:06

and I am getting 3

play12:08

so why should I put extra parenthesis

play12:10

when my work is done without parenthesis

play12:12

so this thing you should know

play12:14

now along with that

play12:16

if I talk to you

play12:18

about another expression

play12:20

b square minus 4ac upon 2a

play12:22

which is your quadratic

play12:24

quadratic equation the discriminant of quadratic equation

play12:27

b square minus 4ac

play12:29

and minus b plus minus under root b square minus 4ac upon 2a

play12:33

which is the root of it

play12:35

but b square minus 4ac upon 2a is our question

play12:37

so if I comment this out and write

play12:39

k is equal to

play12:41

see square is nothing

play12:43

you have to do b into b

play12:46

and let me

play12:48

comment out what is going on

play12:52

so b square

play12:54

minus 4

play12:56

a c

play12:58

and here I will write upon 2 a

play13:00

and I have not given

play13:02

value of b, a or c

play13:04

so I will give that also so I will give here and I have not given value of b, a, c

play13:05

so I will give that also here

play13:07

so I will give value of expression here

play13:09

int b is equal to 1

play13:11

int c is equal to 4

play13:13

and int a is equal to 5

play13:17

like this

play13:19

so I think I have already defined b and a

play13:21

so I will comment out these

play13:23

and this code that I am giving you I am giving you just to refer you it is not like I have defined it, so I will comment it out and this code that I am giving you

play13:26

I am giving you to refer, it is not like I have distributed any software to you

play13:30

so don't say that it is defined twice

play13:33

so I am telling you, so according to that I have given

play13:36

b is equal to 1 and c is equal to 4

play13:39

we did, now what will happen first

play13:42

what will be evaluated first, first these star will be evaluated, star and slash will be evaluated first first of all, these star and slash will be evaluated

play13:48

in which order they will be evaluated, in this direction

play13:50

so b square will be evaluated first

play13:52

then 4, a, c will be evaluated

play13:56

then it will be divided by 2

play13:58

and whatever result will be there, it will be multiplied by a

play14:00

here this is a mess, see the result will be multiplied by a

play14:02

so a means it will come up

play14:04

so no, I don't want a so what i will do

play14:06

to correct this i will put parenthesis

play14:09

here i will put parenthesis

play14:12

and here i will put parenthesis

play14:15

so now see what is the value

play14:18

now value is coming

play14:19

minus 7

play14:22

and if i remove parenthesis then what will it come? then it will come separately

play14:25

see what is coming here

play14:26

then here minus 199 is coming

play14:29

that means something else is happening

play14:31

something else is happening now

play14:32

so I want this value

play14:34

ok

play14:35

like this

play14:37

so I put parenthesis

play14:40

like this

play14:41

so whenever you have a complicated expression

play14:43

then parenthesis is recommended

play14:44

because if you put parenthesis because you will not get any loss by putting parenthesis

play14:46

but you should know about precedence and associativity

play14:51

it is a very important concept

play14:52

so you can write b2-4ac like this

play14:56

what will it do first

play14:57

the most precedence is of parenthesis

play14:59

so parenthesis overwrites this thing

play15:01

I will show you

play15:02

highest 14 precedence

play15:03

see this is of parenthesis

play15:04

here parenthesis

play15:06

here parenthesis will take maximum percentage

play15:08

and after taking

play15:10

here this value will be first

play15:12

then this value will be first

play15:14

then this b square will be first

play15:16

then this divided by this and this will be minus

play15:18

and your result will be here

play15:20

so if i take b and a both as 0

play15:22

here then my result

play15:24

should be 0

play15:26

and it will be 0, see

play15:28

it will have to be 0

play15:30

and if I take a as 0

play15:32

then actually denominator is becoming 0

play15:34

so I do one thing, I make it 10 and make c as 0

play15:36

if denominator is 0 then you will get arithmetic exception

play15:40

exception means that you will have some problem while evaluating your expression

play15:44

now here it will be 0, see now it is zero

play15:46

okay

play15:47

so denominator should not be zero

play15:48

there is a rule of mathematics that if your denominator is zero

play15:52

then expression is undefined and undefined will give you trouble in programming languages

play15:57

sometimes in the form of error

play15:59

sometimes your program will misbehave

play16:01

so you definitely don't want this

play16:03

okay so this was about our operator of precedence, I hope I could explain you associativity,

play16:08

I could explain you precedence, these two concepts are such that to be very honest

play16:12

I will be very transparent with you, I also understood this concept very late in my career,

play16:18

when I used to give exams, I did not understand this,

play16:22

I want to be very transparent with you you but I understood when I came to know how expressions are evaluated

play16:29

and that's why I have given priority to this topic and explained it to you

play16:33

so earlier I used to put a board mask and all at one time

play16:36

star slash and I used to get very worried about these topics

play16:39

but time has gone and I understood these things

play16:44

and today I am explaining to you too, so I want you to understand all these things in a very early stage

play16:48

and these things become important from the point of view of interview, from the point of view of exam

play16:52

from the point of view of exam, all these things become very important

play16:54

so I will explain to you in this way that you should not face any problem

play17:00

at least you should not face the problem that I have faced

play17:03

so if you like the video then like it

play17:06

and if you are taking screenshot of this video

play17:08

and sharing it on instagram

play17:10

then tag me so that I can put your story again

play17:13

and if you like the video then like it

play17:15

I am not just saying it

play17:17

many of you like the video from the heart

play17:19

so if you like the video from the heart then like it

play17:21

I don't want to irritate you by saying

play17:23

like it, like it,ate you if you like this video

play17:27

then like the upcoming videos

play17:29

thats it for now

play17:32

thank you so much for watching this video

play17:34

and i will see you next time Thank you for watching.

Rate This

5.0 / 5 (0 votes)

関連タグ
Java BasicsOperator PrecedenceAssociativityJava TutorialCoding TipsExam PrepProgramming ConceptsMath RulesExpression EvaluationInterview Questions
英語で要約が必要ですか?