
-----------------------------------
agnivohneb
Wed Oct 21, 2009 12:30 pm

error at readLine
-----------------------------------
I have been taking some classes for java and I have a problem that i cant seem to solve

the error is 
The method "java.lang.String readLine() throws java.io.IOException;" can throw the checked exception "java.io.IOException", so its invocation must be enclosed in a try statement that catches the exception, or else this method must be declared to throw the exception.

i get this error at every instance of in.readLine()

here is the code
import java.util.*;
import java.io.*;

public class CalcuGator
{
    public static void main (String
public class Calc
{
    public static double num1;
    public static double num2;

    public static String divide ()
    {
        if (num2 == 0)
        {
            return "Cannot divide by 0";
        }
        else
        {
            return Double.toString(divideNoErr ());
        }
    }


    public static double divideNoErr ()
    {
        return num1 / num2;
    }


    public static double multiply ()
    {
        return num1 * num2;
    }


    public static double add ()
    {
        return num1 + num2;
    }


    public static double subtract ()
    {
        return num1 - num2;
    }
}


Could anyone tell me what that error means and how i can solve this problem? thanks

-----------------------------------
agnivohneb
Wed Oct 21, 2009 12:34 pm

RE:error at readLine
-----------------------------------
never mind i figured it out... i forgot to add throws IOException to main
