A twin prime is a prime number that differs from another prime number by exactly 2. For
example, 3 and 5 are twin primes, since 3 and 5 are each prime and differ by 2
(likewise, 5 and 7 are also twin primes).
Complete the twins() method, which takes an integer argument n and prints all the
sets of twin primes that are less than n, one pair per line. The method does not return
any value. For example, twins(15) would print
(3, 5)
(5, 7)
(11, 13)
Use the sieve() method from Part 1 to generate the initial list of prime numbers.
This is what I have:
public static void twins (int max)
{
ArrayList<Integer> twins= sieve(max);
new ArrayList<Integer>(max);
int index = 0;
for (index = 0; twins.size() - 1 > index; index++)
{
if (twins.get(index+1) - twins.get(index) == 2)
{
System.out.println(twins.size()+","+ twins.size());
}