Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

class 1

 
Shawn Mountcastle
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm stuck on Assignment 1.2 (EvenOrOdd) and can't figure out what I'm doing wrong. The error message I get is: "method If (boolean) not found in class EvenOrOdd."
Here's the program (so far):
public class EvenOrOdd
{
public static void main ( String args [0] )
{
String s = args [0];
int n = Integer.parseInt ( s );
If ( ( n % 2 ) == 0 );
{ System.out.print ( "Even!" );
}
}
}
 
paul wheaton
Trailboss
Pie
Posts: 21736
Firefox Browser IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Remember that Java is case sensitive.
In this case, java does not have a structure called "If" so it's looking for that method (which it cannot find).
Java does have a structure called "if".
 
Shawn Mountcastle
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I thought I posted this question yesterday but I don't see it anywhere, so here it is again:
OOPS. Found it.
[This message has been edited by Shawn Mountcastle (edited May 12, 1999).]
 
Pin Ting
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Matt Midcap:

Solution (for my problem was): One wierd thing about WordPad (on Windows98, not NT) is that although you save your file as a .txt file (HelloWorld.java), it actually saves it as "HelloWorld.java.txt"!
Try going to the DOS prompt, go to where you saved the file and type DIR. If the name is "HelloWorld.java.txt" you'll have to change it manually at the DOS prompt.

Actually, this is more like an OS property setting problem. In the "Folder Options" settings, you can select whether to show the file extension name or not.
 
Marilyn de Queiroz
Sheriff
Posts: 9067
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems that the problem Matt pointed out had more to do with the behaviour of WordPad renaming the file rather than whether it showed the extension or not.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic