Lynk Library of Knowledge

9496 Lynk's site for housing knowledge and information for the team.


Project maintained by LynkRobotics Hosted on GitHub Pages — Theme by Jimmy McCosker

Making a Method



Example


 /*add 4 to the paramter sent to the method and return the result*/
    public static double addFour(double num){   // the varible type before the method name is what type will be returned
        return num + 4;                         //return is the keyword that tells java to end the method and send the value
    }
    
    /*if the boolean named bol is true than print out the double named num*/
    public static void ifTruePrint(boolean bol, double num){    //void means the method won't return any value
        if (bol){
            System.out.println(num);
        }
    }                                                           //this method doesn't return a value










Previous Page / Home / Next Page