如何在java中读取用户Defind函数中的值

时间:2016-05-03 16:39:04

标签: java core

class Testing
{

    public static void ischeck()
    {
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        System.out.println("hello"+a);
        //print value of aa that given by user
    }
    public static void main(String str[])
    {

        ischeck();      

    }
}

**我的要求是在用户定义函数中获取扫描器类值

1 个答案:

答案 0 :(得分:-3)

import java.util。*;

班级测试 {

    public static void someMethod()
    {
    Scanner sc = new Scanner(System.in);
            int  text = sc.nextInt();
    System.out.println(text);
    }
public static void main(String str[])
{

    someMethod();
}

}