で.disjoint方法について与えられ、それはfalseが返され、私はそれがない偽異なる出力は、java
のために真のために割り当てられた文を見せているif文を作成したとき、私は異なる取得しています同じ入力に対する出力が与えられたが、別の形で
import java.util.*;
public class Main {
public static void main(String[] args) {
//convert array stuff to list
String [] stuff = {"apples","beef","corn","ham"};
List<String> list1 = Arrays.asList(stuff);
String[] l1 = {"banana" , "sauna" , "mushroom"};
ArrayList<String> list2 = new ArrayList<String>();
for (String x : l1)
list2.add(x);
list2.add("youtube"); //this is the method for adding extra items or each single item to ARRAYLIST
list2.add("google");
list2.add("facebook");
for (String x : list2)
System.out.printf("%s ",x);
Collections.addAll(list2,stuff); //it takes all the elements from the STUFF and adds them to list2
/**if v create an add all method we could not print the other string*/
System.out.println();
for (String x : list2)
System.out.printf("%s ",x);
System.out.println();
System.out.println(Collections.frequency(list2,"youtube"));
boolean tof = Collections.disjoint(list1,list2);
System.out.println(tof);
if (tof = true) //doudt
System.out.println("these lists donot have anything in common");
else
System.out.println("these lists must have something in commom");
}
問題は単なるミスである - 'IF(TOF =真)'であるべきである ''(== TOF真)であれば - 以上、単に ''(TOF)場合 –