aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes am confusing in operator precednce pls explain me Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "am confusing in operator precednce pls explain me" Watch "am confusing in operator precednce pls explain me" New topic
Author

am confusing in operator precednce pls explain me

giribabu rosi
Greenhorn

Joined: Apr 14, 2005
Posts: 17
1+2*3%4+5/4
Rohan Kayan
Ranch Hand

Joined: Sep 17, 2004
Posts: 123
1+2*3%4+5/4

= 1+((2*3)%4)+(5/4)
= 1+(6%4)+1
= 1+2+1
= 4

As the precedence of * / % are same they will calculate left to right , that's why 2*3 and 5/4 will be the first operation , then 6%4 and then the sum of all three.


SCWCD 1.4, SCJP 1.4
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: am confusing in operator precednce pls explain me
 
Similar Threads
Mock question
Somebody in office on a saturday
Write a getter and setter to each private field
Flow control
Diff between Hashcode and equals