输入函数
Java里怎么输入一个数赋给变量?比如我要从键盘输入一个数给变量A,怎么做?
问题很菜,随便说下
import java.util.Scanner; class Student{ private float m_chinese; private float m_math; private float m_english; private static Scanner read = new Scanner(System.in); public Student(){ } public void InPut(){ m_chinese = read.nextFloat(); m_math = read.nextFloat(); m_english = read.nextFloat(); } public class ScoreTest { public static void main(String[] args) { Student[] stu = new Student[3]; for (int i=0; i<3; i++){ stu[i] = new Student(); stu[i].InPut(); stu[i].Print(); } } }