java - Method Overload Error -
my velocity method keeps giving me error saying
"no applicable overload method named 'velocity' found in type "velocity". perhaps wanted overload version 'void velocity (double distance, double time) throws java.io.ioexception;' instead?"
i'm not sure how can prepare this, if guys can help, great, thanks.
anyways, here code:
import java.io.*; public class velocity { public static void main (string[] args) { velocity (); } public static void velocity (double distance, double time) throws ioexception { bufferedreader myinput = new bufferedreader (new inputstreamreader (system.in)); system.out.println ("please input distance in meters:"); distance = double.parsedouble (myinput.readline ()); system.out.println ("please input time in seconds:"); time = double.parsedouble (myinput.readline ()); system.out.println ("therefore velocity " + distance / time + " m/s."); } }
you trying phone call method velocity (); instead should call
velocity (1d, 2d);
this reason error.
regarding overloading:
if have method same name like:
public static void velocity() throws ioexception () { //body }
then overloading method velocity here. define , should work.
java methods overloading velocity
No comments:
Post a Comment