Can't return the answer

The answer should be returned but it does not display for some reason. I have printed within for loop and seen that it's correct answer.

public class Salary
    public static void main (String[]args)
        double [] salary = {20000.00};
        double riseRate = 1.07;

        calculateSalary(salary, riseRate);
    public static double [] calculateSalary(double [] salary, double riseRate)
        for (int i=0; i<salary.length; i++)
            salary [i] = salary [i] * riseRate;
        return salary;


You are returning an array. The salary is in the the first position of you array. If you want to see the salary you would need to use

return salary[0];

in your method.



in the main.

What you're trying to print right now is the actual array, not a value.

I am not sure why you are doing it like this, though. Why not just use a double instead of double[]?

That's because you're not printing out the answer. Add a print statement in main.

System.out.println(calculateSalary(salary, riseRate)[0]);

Need Your Help

Are pull requests part of Git, or a feature of tools like GitHub, Gerrit and Atlassian Stash?

git github gerrit pull-request bitbucket-server

Pull requests seem to be the common way to do code review with Git. However, it is not clear whether this term means the same when using the built-in git request-pull, or a different tool.

how to use javascript to validate xml against schema in firefox?

javascript xml xsd activexobject

I can do this in IE using ActiveXObject, however mozilla doesn't support ActiveXObject. Is there any way I can use JS to validate an XML against an XSD schema in firefox?