import java.util.Scanner;
class get{
int gInt=0;
public int getInt(){
Scanner sc=new Scanner(System.in);
System.out.println("please input a Int :");
gInt=sc.nextInt();
return gInt; //写返回值用return 就可以了。
}
}
public class Test{
public static void main(String[] args){
System.out.println("the num is :"+new get().getInt());
}
}
完整代码如下:
public class Test{
public static void main(String[] args) {
int num = 13;
Get get = new Get();
System.out.println(get.get(num));
}
}
class Get{
public int get(int num){
return num;
}
}
class get{
public int get(int a){
return a;
}
}
就像这样
好简单的题目啊
class get{
public int get(int a){
return a;
}
}