I am new to java. I am trying to create 3 methods within a class and then call them in that same class. I am not creating or calling correctly. Please help. Here's my code:
Java doesn't allow you to declare methods within another method. So move the three methods outside of main.
Now if you call these methods from main you must, either declare them static (just like main), or
instantiate Ch4_PrExercise2 using new and then use the reference to call the methods like,
Ch4_PrExercise2 e = new Ch4_PrExercise2(); // first thing in main
//
e.largest() // later in main
Finally you must either move
int num1, num2, num3;
outside of main, or pass these variables as parameters to the methods, or both.
Last edited by nuzzle; September 18th, 2011 at 11:54 PM.
Bookmarks