This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes < operator Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "< operator" Watch "< operator" New topic

< operator

vineet walia
Ranch Hand

Joined: Feb 16, 2008
Posts: 138

1st syso statement give error which is
The operator < is undefined for the argument type(s) String, int

but if < operator can not be operate on int then why 1st syso statement is executing ??
avi sinha
Ranch Hand

Joined: Mar 15, 2009
Posts: 452

the reason here is the "string" before the digits you want to compare.

and you can't compare a string with a number. you should write "direct output"+(5<6) it will work for sure.

avi sinha

SCJP 5.0 SCWCD 5.0
Lucas Smith
Ranch Hand

Joined: Apr 20, 2009
Posts: 804

It's only operator precedence.

S Bhanage

Joined: Oct 28, 2009
Posts: 13
Use the following

System.out.println("direct output"+(5<6));

It works fine.
jQuery in Action, 2nd edition
subject: < operator
Similar Threads
Simple precedence question.
LinkedHashMap - trying to use the method removeEldestEntry
Want to convert my code in method
How to set value in jtable fields??
please explain its output