Example 5.1.2
//pag 48 http://www.greenteapress.com/thinkapjava/thinkapjava.pdf
 
public class example_5_1_2    
{
 
    public static double absoluteValue(double x) {
        if(x < 0){
            return -x;
        }else{
            return x;
        }
    }
 
    public static void main(String [] args) {
        //code
        double a = -3.3;
        System.out.println(absoluteValue(a));
    }
}

voltar

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.