How would I be able to run both of these classes in one executable file. I'm new to this so sorry if the answer is very simple. I would appreciate it if you were able to walk me through it. Thank you for taking the time to respond.
import java.util.HashSet;
public class Prog2 {
public static boolean sameElements(int[] A, int[] B){
boolean same = false;
HashSet<Integer> hashSet = new HashSet<Integer>();
for(int i = 0; i < A.length; i++){
hashSet.add(A[i]);
}
for(int i = 0; i < B.length; i++){
if(hashSet.contains(B[i])){
hashSet.remove(B[i]);
}
}
if(hashSet.isEmpty()){
same = true;
}
return same;
}
}
public class Prog3 {
public static void inRun(int[] A){
boolean inRun = false;
for(int i = 0; i < A.length; i++){
if(inRun) {
if (A[i] != A[i - 1]) {
System.out.print(')');
inRun = false;
}
}
else{
if(i + 1 < A.length && A[i] == A[i + 1]){
System.out.print('(');
inRun = true;
}
}
System.out.print(" " + A[i] + " ");
}
if(inRun){
System.out.print(')');
}
}
}