aspose file tools*
The moose likes Cattle Drive and the fly likes class 1 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » This Site » Cattle Drive
Bookmark "class 1" Watch "class 1" New topic
Author

class 1

Shawn Mountcastle
Greenhorn

Joined: Feb 09, 1999
Posts: 26
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

Joined: Dec 14, 1998
Posts: 20271
    ∞

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".

permaculture Wood Burning Stoves 2.0 - 4-DVD set
Shawn Mountcastle
Greenhorn

Joined: Feb 09, 1999
Posts: 26
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

Joined: May 28, 2003
Posts: 22
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.


Never do things the hard way if you don't have a good reason.
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9043
    
  10
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.


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: class 1
 
Similar Threads
first assignment - need help
Running a Program from Elements in its Title
A dumb question, i know.........
class 2
style guide