use*_*725 -1 java methods compiler-errors class
// Simple program to understand pass by reference
import java.util.*;
public class HelloDate {
public static void main(String args[])
{
class Number // Contains only an integer
{
int i;
}
static void f(Number k) // <<--- Illegal start of expression ???
{
k.i = 22;
}
Number n1 = new Number(); // New object of Number
n1.i = 9;
f(n1); //Passing an object
System.out.println(n1.i); // Print
}
}
Run Code Online (Sandbox Code Playgroud)
代码显示错误static void f(Number k).我应该把这个方法void f()放在课堂上吗?如果是,为什么这是必要的?
| 归档时间: |
|
| 查看次数: |
515 次 |
| 最近记录: |