File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes first java am stuck Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "first java am stuck" Watch "first java am stuck" New topic
Author

first java am stuck

yoga nina
Greenhorn

Joined: Aug 13, 2011
Posts: 5
I have wasted all weekend trying to sort this out. If anyone can help i'd so appreciate it.
This is suppossed to be a leap year calculator. The values of the variables were given.
I thought I had worked it out all right but my if (and, or) staement keeps getting a error " bad operand types for binary operator ||"
I promise to read the FAQs when I have more time,
Cheers

Suhas Mandrawadkar
Ranch Hand

Joined: Jul 21, 2007
Posts: 72



R3 = 0 does not evaluate to a boolean. It is just an assignment.
'=' - assignment operator
'==' - equality operator.

Read more on operators - Equality, Assignment and Logical


Regards, Suhas S. Mandrawadkar.
Certifications: SCJP 6, SCWCD 5, Oracle WebLogic Server Administrator, OCE Java EE 6 EJB Developer
Kurt Van Etten
Ranch Hand

Joined: Sep 07, 2010
Posts: 98
Hi,

In your program line: you've got one too few "=" in your R3 comparison, so it is actually an assignment. This is a fairly common newbie error. One nice thing about Java is that it will catch this kind of error at compile time. In a language like C or C++, the assignment R3 = 0 will be treated logically as false no matter what value R3 had going into the expression. (It looks like you may have some other syntax errors in your code as well, but one at a time!)

By the way, one of the things the FAQ may mention is that you should surround your program excerpts in code brackets (you can use the button at the top of the message editor). That will display your code with formatting for easier reading.
yoga nina
Greenhorn

Joined: Aug 13, 2011
Posts: 5
still stuck
Thanks guys but the missing = was just a silly typo on my part.
The message still comes up "illegal start of expression, bad operand types for binary operator ||, first type int, second type boolean"
I just don't get this as all my varaibles are int, the operators are boolean, but yeah so?
cheers, guys
will read FAQ in morning
Suhas Mandrawadkar
Ranch Hand

Joined: Jul 21, 2007
Posts: 72

You also have an extra "=" in "!==" and a semi colon at the end of line. It should be



Sorry, my bad. I could not point it out earlier
yoga nina
Greenhorn

Joined: Aug 13, 2011
Posts: 5
Thanks Suha, you're a star.
All done, can get some rest now.
Bless you
Suhas Mandrawadkar
Ranch Hand

Joined: Jul 21, 2007
Posts: 72

Glad, I could be of your help.
But please do read more on operators - Equality, Assignment and Logical. You got all of them wrong together in a single Line of Code.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36478
    
  16
Welcome to the Ranch

Confusing == and = is a very common mistake.
Angus Comber
Ranch Hand

Joined: Jul 16, 2011
Posts: 90
I hope this example might be useful.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: first java am stuck
 
Similar Threads
Question on static
garbage collection query
Problem in understanding output of Program
garbage collection question
Java Free Blocks