我有这四个类,我想更改 for 循环中使用的变量
我主要想从 Comment.getComment 方法中更改 curLine 变量
URLReader.java
public class URLReader {
ParseHTML ParseHTML = new ParseHTML();
public static void main(String[] args) throws Exception {
URLReader URLReader = new URLReader();
URLReader.ParseHTML.parseHTML();
}
}
解析HTML.java
public class ParseHTML {
int curLine = 0;
Comment Comment = new Comment();
CharacterAndLine CharacterAndLine = new CharacterAndLine();
public void parseHTML() {
for (curLine = curLine; curLine < 100; curLine++) {
curLine = CharacterAndLine.getCurrentLine()+curLine;
System.out.println(curLine);
}
}
}
评论.java
public class Comment {
CharacterAndLine CharacterAndLine = new CharacterAndLine();
public void getComment() {
CharacterAndLine.setCurrentLine(50);
}
}
CharacterAndLine.java
public class CharacterAndLine {
int currentLine;
public int getCurrentLine() {
return currentLine;
}
public void setCurrentLine(int newCurrentLine) {
currentLine = newCurrentLine;
}
}
如果不是 getter 和 setter,我需要以某种方式更改 curLine 变量。