package com.dsme;public class Student { private String stuNo;
private String stuName;
private int stuScore;
//显示学生分数
public void displayScore()
{
System.out.println(stuScore);
}
//显示学生详细信息
public void displayDetail()
{
System.out.println(stuNo);
System.out.println(stuName);
}
//构造函数
public Student()
{
stuNo = "001";
stuName = "Jack";
stuScore = 0;
}
public Student(String stuNo,String stuName,int stuScore)
{
this.stuNo = stuNo;
this.stuName = stuName;
this.stuScore = stuScore;
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Student stu = new Student();
stu.stuName = "Tome"; //这行会提示错误吗
stu.displayDetail();
stu.displayScore();
}}
sut.stuName = "Tome" 这行会不会出现错误,为什么.在我的系统中运行为什么没有提示错误呢??
private String stuName;
private int stuScore;
//显示学生分数
public void displayScore()
{
System.out.println(stuScore);
}
//显示学生详细信息
public void displayDetail()
{
System.out.println(stuNo);
System.out.println(stuName);
}
//构造函数
public Student()
{
stuNo = "001";
stuName = "Jack";
stuScore = 0;
}
public Student(String stuNo,String stuName,int stuScore)
{
this.stuNo = stuNo;
this.stuName = stuName;
this.stuScore = stuScore;
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Student stu = new Student();
stu.stuName = "Tome"; //这行会提示错误吗
stu.displayDetail();
stu.displayScore();
}}
sut.stuName = "Tome" 这行会不会出现错误,为什么.在我的系统中运行为什么没有提示错误呢??
不过这样写很不好,除非你这个变量是static