File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

modolo operator on RR3

 
Jimmy Bonds
Ranch Hand
Posts: 38
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 6529
21
Java Linux Mac Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use "==" for comparing two things for equality. "=" assigns the value on the right side to whatever is on the left side.
Junilu
 
Jimmy Bonds
Ranch Hand
Posts: 38
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
DOH!!!

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic