Hi, I'm writing my first program for my second year comsci class and I'm still learning java along the way. Anyways, the signature for one of my functions has to be:
"public static BigInteger fNumberRoutes( int n, int m )"

So I assume it's a function that returns a BigInteger.

Here's my code:

public static BigInteger fNumberRoutes( int n, int m ){
		try{			
			if (n<0 || m<0) 
			{			
				throw new IllegalArgumentException("WTF?");
	 		}
		}
		catch (IllegalArgumentException iAE){
			System.out.println("Negative integer detected");			
			System.exit(1);
		}
		return 0;	
	}
}

Now, it doesn't really do anything yet, but this is my stub code. I get the following error message:
"CountRoutes2.java:29: cannot find symbol
symbol : class BigInteger
location: class CountRoutes2
public static BigInteger fNumberRoutes( int n, int m ){
^
1 error"

Not sure what I'm doing wrong. Maybe I don't completely understand what a BigInteger is, but I copied the assignment's signature exactly.

Thanks for the help.

did you import the math api?

import java.math.BigInteger;

"cannot find symbol" usually means that you didn't declare a variable or somethings not picking up in the method signature.

What IDE are you using? the error message references 29, which I'm assuming is the line number of the code. Can you provide the specific code on that line#. I think when you copied and pasted it just defaulted to say line 1 through 14.

Yeah, the line I posted is 29 so that's where the problem was. I didn't import it, but now I did and it says I can't return 0. Can anyone give me an explanation of how to work BigInteger? It's a class so I need to create a BigInteger object?

yeah, your going to have to make an object first to use BigInteger. I think the return 0 is throwing it off, b/c it needs to return a BigInteger. If its setup in the signature, you need to return the same data type.

so for example:

public static BigInteger fNumberRoutes( int n, int m ){
    BigInteger bigIntegerObject = new BigInteger("123");
    return bigIntegerObject;
}

what's the try/catch statement for? I'm not sure what you're doing with the throws clause. It looks like you're trying to see if an integer is negative, but then why would you need to use BigInteger?

hope this helps somewhat

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.