English 中文(简体)
Java - 日食错误: 转让的左手侧必须是变量
原标题:Java - Error in eclipse: the left hand side of an assignment must be a variable
  • 时间:2012-05-24 18:39:29
  •  标签:
  • java
  • eclipse

这是我的代码的一小部分。 我的项目是模拟整个学校系统。 添加教师、 课程等等。 我所有的班级成员都是私人的, 所以我创建了设置器和获取器方法。 我试图给老师一个数值, 这必须是自动的( 而不是从键盘上) 。 所以, 如果第一个老师等的话, 我想给它一个数值。 我希望你能理解。 抱歉我的英语 。

public void addTeachersList(Teachers teachers) {
   if(this.teachersSize<100){
     this.teachersList[this.teachersSize] = teachers;
     this.teachersList[this.teachersSize].getTeacherNum() = this.teachersSize -1;
     this.teachersSize++;
   }
} 
最佳回答

你得叫个修理工:

this.teachersList[this.teachersSize].setTeacherNum(this.teachersSize-1);

打电话去叫老师 刚刚给了你号码, 它不是那个财产的参考。

虽然我必须说,你真的帮了自己一个忙, 使用 < code> list 执行, 而不是数组 。

问题回答

依此线线

this.teachersList[this.teachersSize].getTeacherNum() = this.teachersSize -1;

getTeacherNum () 返回一个值。 您无法指定它 。

你这里有问题

this.teachersList[this.teachersSize].getTeacherNum() = this.teachersSize -1;

。getTeacherNum () 会返回必须在左侧变量中存储的值。

示例 :

临时 =. get TeacherNum ();

最好用静态变量来保持教师人数的统计, 所以每次老师被创建时, 老师就会得到一个与前一个不同的东西,

示例 :

 xxxx001
 xxxx002
 xxxx003

你这里有问题

this.teachersList[this.teachersSize].getTeacherNum() = this.teachersSize -1;

.getTeacherNum () 将返回必须在左侧变量中存储的值 。

包括: temp =.getTeacherNum () ;

最好用静态变量来保持教师人数的统计, 所以每次老师被创建时, 老师就会得到一个与前一个不同的东西,

示例 :

xxxx001
xxxx002
xxxx003




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签