1.1、已知函数
                      x + 3   ( x > 0 )
               y =      0     ( x = 0 )
                      x2 –1  ( x < 0 )
请设计一个方法实现上面的函数,根据传入的值x的不同,返回对应的y值。

public class Test02 {
public static void main(String args[]) {
int y = function(0);
System.out.println(y);
}
public static int function(int x) {
int y;
if (x > 0) {
y = x + 3;
} else if (x == 0) {
y = 0;
} else {
y = x * x - 1;
}
return y;
}
}