2013年10月5日星期六

Help: function call problems - determine whether two integers are equal , call the function does not print

class FunctionDemo
{
public static void main (String [] args)
{
equals (7,5);
}
public static boolean equals (int a, int b)
{
if (a == b)
return true;
else
return false;
}
}
------ Solution ----------------------------------- ---------

public class FunctionDemo {
public static void main(String[] args) {
System.out.println(equals(7, 5));
}

public static boolean equals(int a, int b) {
if (a == b)
return true;
else
return false;
}
}

------ For reference only ----------------------- ----------------
sorry first post, how out format is so ah , declare that I am writing format compliant , the compiler also through , just do not print true, or false. May I ask where is the problem !
------ For reference only -------------------------------------- -
ask why the output statement must use it, can not directly call the function equals do ? Because I 'm learning video , there is a definition of a void function , the console print out a rectangle , the function of which used for nesting , and then calls the main function directly , you can of
----- - For reference only ---------------------------------------


what you write on your computer do what .
You did not write output statements to your own computer does not output
------ For reference only --------------------- ------------------
Thank you ! Keep up the good

没有评论:

发表评论