• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

relational operators

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
system.out.println(3>2);
the output is true.
how it happens
generally we compare the variables containg value
even the following code snipet behave similar.
system.out.println(3==3);
why the relational operators behaviour is like this
 
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi jagadish.
Both lines of code produce true. 3 is greater than 2 & 3 is equal to 3. I'm not sure if this is what you were asking, hope it helps, Dave.
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
System.out.println(3>2)
Inorder to carryout an operation the expression needs to evaluated. so the expression on either side of the relational operator(left to right)
are evalauted. This expression must evalaute to a value of numeric type. The expression '3' and '2' are constant expression(compile time constants as they always evaluate to a value) of type integer ,hence they behave in the same way as
int p,=10,q=20;

System.out.println(p>q) where p and q will
evaluate to value of numeric type
Hope this helps
thank u,
Saravanakumar R
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic