쉬운 질문이지만 미안하지만 다른 클래스의 매개 변수로 내 메서드를 호출 할 수 없습니다.다른 클래스의 매개 변수가있는 메서드에 액세스
일반적으로 내 메서드를 호출하면 그렇게 할 것입니다.
클래스 1
public static void main(String [] args){
Class2 class2Object = new Class2();
class2Object.myMethod();
}
Class2의 위
public void myMethod(){
System.out.print("Hello");
}
그냥 예입니다,하지만 난 (예를 들어 ArrayList에을)를 MyMethod라는 방법으로 매개 변수를 전달해야한다면, 어떻게 부를 것이다 그것은 다른 클래스에 있습니다.
내가 호출 할 필요가 실제 방법은 다음과 같습니다 :
public void search(List<String> listOfWords) throws FileNotFoundException, IOException
어떤 도움을 이해할 수있을 것이다, 감사합니다.
List<String> someList = new ArrayList<String>();
//populate list if you want
class2Object.search(someList);
당신은 아마 a tutorial on methods arguments을 읽고 도움이 될 :를 호출 할 때
당신은 무엇을하려고 않았다처럼 당신이 전화를 전달하고자하는 정보와 데이터 유형 및 당신이 그것을 참조 할을 추가? 너 무슨 문제있어? – SLaks
내 오류를 발견했습니다. 걱정하지 마십시오. – Digitalwolf