| Author |
Brackets { } .........
|
Steve Jensen
Ranch Hand
Joined: Sep 23, 2002
Posts: 126
|
|
I've been typing in examples from a chapter on Methods, and I thought I understood what was going on. Until now. My problem concerns the use of brackets { } when writing code. Below is what I thought the solution to a factorial problem - this is my solution. Well, when I say 'my' solution, I mean the book code, but with as much of it as possible anticipated by me and written, only looking at the book when stuck. There is a syntax error in it, and for the life of me, I can't figure out where it is. Below is the book solution, which compiles and runs fine. I think there error in my solution lies in the use of the { } brackets. Can anybody see what I've done wrong, and why? I have spent HOURS breaking my thumbs trying to figure it out, but to no avail.
|
John Bonham was stronger, but Keith Moon was faster.
|
 |
Ashish Hareet
Ranch Hand
Joined: Jul 14, 2001
Posts: 375
|
|
Hi Steve, Here's a revised version of your code - Notice that I finished off with the main method & then went on to write the next method f i.e you need one "}" before static long f(.. & you gotta remove one "}" from the end. HTH
|
 |
Steve Jensen
Ranch Hand
Joined: Sep 23, 2002
Posts: 126
|
|
Doh!! I see now. I failed to notice that the main method, must be enclosed by { } just like any other method should be. Cheers for the help!
|
 |
 |
I agree. Here's the link: jrebel
|
|
subject: Brackets { } .........
|
|
|