jQuery in Action, 2nd edition*
The moose likes Beginning Java and the fly likes modolo operator on RR3 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 » Java » Beginning Java
Bookmark "modolo operator on RR3" Watch "modolo operator on RR3" New topic
Author

modolo operator on RR3

Jimmy Bonds
Ranch Hand

Joined: Jun 05, 2001
Posts: 38
class LeapYear
{
int year;

int getY(int i)
{
year=i;
return year;
}

void leepY()
{
if((year%100=0)|(year%400=0))
{
System.out.println("Not a Leap Year!");
}
else if(year%4=0)
{
System.out.println("Leap Year!!");
}
else
{
System.out.println("not a Leap Year!");
}
}
}
Hi all,
When I run the preceeding code I get a compile error saying-
"invalid left hand side of assignment:
if((year%100=0)|(year%400=0))"
^
It's my understanding that the expression to be evaluated should be on the left, such as: 10%3=1.
Where 10 is the expression.
Please set me straight!

Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4442
    
    5

Use "==" for comparing two things for equality. "=" assigns the value on the right side to whatever is on the left side.
Junilu


Junilu - [How to Ask Questions] [How to Answer Questions]
Jimmy Bonds
Ranch Hand

Joined: Jun 05, 2001
Posts: 38
DOH!!!

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: modolo operator on RR3
 
Similar Threads
please verify this code
enter a value
unreachable statement error
Leap Year program
first java am stuck