Hello guys,
I would like to write a code which look for if elements exist in other table so poszukiwane in dane.
If three or more elements are the same it will outputs true, else false.
1. My output count always only once and gives false all the time. How to fix it?
2. I wanted to make it with public static boolean MyMethod(char[] dane, char[] poszukiwane), but I'm not sure how to make, can you suggest sth?
public class Testjava { public static void main(String[] args) { char[] dane = new char[]{1, 2, 4, 6, 7, 8, 15}; char[] poszukiwane = new char[]{1, 2, 4, 7, 15}; int count = 0; for (int i = 0; i < dane.length; i++) { for (int j = 0; i < poszukiwane.length; i++) { if (poszukiwane[j] == dane[i]) { count = count + 1; } else { ; } } } System.out.println(count); if (count >= 3) { System.out.println("True"); } else { System.out.println("False"); } } }