2 つの質問があります。私は Java の初心者ですが、巨大な Java プロジェクトを持っています :(
クラス (2 つの void メソッドを持つインターフェイス) を実装し、クラスに別のメソッドを記述しようとすると、コンパイルは実行されますが、実行時にメソッドがスキップされますか? 私は何が間違っているのでしょうか?
メインではない別のクラスからクラスを実行するにはどうすればよいですか。基本的に、メインは別のクラスを呼び出すクラスを実行します...
これらの質問は内容がかなり限られていることは知っていますが、プログラムはすべてを説明するのが不可能なため、非常に複雑です:(
どんな助けでも大歓迎です:)ありがとう!!
--- 更新 - 要求に応じて
class FriendLists implements Results {
public void processCommunication (Communication d) {...}
public void postProcess() {...}
//the above two run perfectly
//I don't know what to do next.
//I'm trying to create a link to my other class, to use the values values
//but when compiled and running it skips this method (and all other methods except the above two
public void processCommunication(AggregatedDirect f) {
//does something from the class I'm trying to run
man = f.getNumTargets(); //getNumTargets is a value in the AggregatedDirect Class
}
、
interface Results {
void processCommunication (Communication c) throws SAXException;
void postProcess();
}
、
public class AggregatedDirect extends Communication {
ArrayList<Integer> targets;
public AggregatedDirect(Direct d) {
super();
targets = new ArrayList<Integer>();
this.type = d.getType();
this.invocSerial = d.getInvocSerial();
this.serial = d.getSerial();
this.usage = d.getUsage();
this.messageType = d.getMessageType();
this.characterID = d.getCharacterID();
this.characterStatus = d.getCharacterStatus();
this.locationID = d.getLocationID();
targets.add(d.getTargetCharacterID());
this.targetCharacterID = -1;
this.targetCharacterStatus = -1;
this.targetCharacterLocationID = -1;
this.message = d.getMessage();
this.time = d.getTime();
this.annotation = d.getAnnotation();
}
public void addTarget(int targetCharacterID) {
targets.add(targetCharacterID);
}
public void addTarget(Direct d){
addTarget(d.getTargetCharacterID());
}
public int getNumTargets() {
if (targets == null)
return -1;
else
return targets.size();
}
public ArrayList<Integer> getTargets() {
return targets;
}
}
- ここにクラスを記述
Communication
します。 - すべての通信の抽象スーパークラス
- サブクラス。
実際には - XML ファイルを処理して分離します
- Direct は通信を拡張します // 基本的に XML ファイル内の文字列値の 1 つです