-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathq2.java
More file actions
23 lines (19 loc) · 670 Bytes
/
Copy pathq2.java
File metadata and controls
23 lines (19 loc) · 670 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
public class q2 {
public static void printAllPairs(int[] arr) {
// Print all possible pairs of numbers using enhanced for loops
for (int first : arr) {
for (int second : arr) {
System.out.print("(" + first + ", " + second + ") ");
}
System.out.println(); // New line after each row
}
}
public static void main(String[] args) {
// Example array
int[] numbers = {1, 2, 3, 4};
System.out.println();
System.out.println("All pairs from the array:");
System.out.println();
printAllPairs(numbers);
}
}