File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 Make it so: Java DB Connections & Transactions this week in the JDBC 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: 453

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: 808

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.
I agree. Here's the link:
subject: < operator
It's not a secret anymore!