Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

>> REGISTER NOW TO START POSTING

1. ## ArrayList of longs

I'm following in the footsteps of the 100K people who have gone before me in trying to solve some of the project Euler problems. The challenge is to calculate the highest prime factor of a given number. My current solution works perfectly for integers... the problem is that project euler wants me to calculate a long, and I'm not sure I can use longs in ArrayLists.

```import java.util.*;

public class PrimeFactors {

public static List<Integer> primeFactors(int numbers) {
int j = numbers;

List<Integer> factors = new ArrayList<Integer>();
for (int i = 2; i <= j / i; i++) {
while (j % i == 0) {
j /= i;
}
}
if (j > 1) {
}
return factors;
}

public static void main(String[] args) {
int inputValue = 0;

if (args.length > 0) {
inputValue = Integer.parseInt(args[0]);
} else {
}
for (Integer integer : primeFactors(inputValue)) {
System.out.println(integer);
}
}
}```

Much appreciated if somebody could help point me in the right direction.