I don't know how to use ArrayList to print these values, I need to print the results with 1 number on each line with the specific values it contains like
0 is prime, odd
1 is prime
2 is prime, odd
This is what I have
Thank you for any help
Don't write if (something) return true; else return false;
Look in the old Sun style guide for what you should write.
There are much better ways to work out whether a number is prime.
Don't have lots of methods for divisibility. Look how much repeated code you have. Have one method taking the divisor as a parameter.
Look very carefully at your isOdd method and see if you can't see anything odd about it.
I have to use those methods for divisibility its a requirement for the homework question. I fixed the odd method i think, I removed the unnecessary brackets if that's what you meant. I think the main point of this assignment is to make use of ArrayList and implement these methods through ArrayList which i haven't done before.
In that case you probably want a proper concrete class. Remove all the instances of the keyword static except before the main method.
Ryan Gordon wrote:'m not 100% if I want a utility class or not . . .
Which looks to me like being given homework to write poor quality code
I have to use those methods for divisibility its a requirement for the homework question. . . .
No, it isn't. Don't go thinking that brackets are unnecessary or can be removed right left and centre. Sometimes brackets are optional, but no, my suggestion for change had nothing to do with brackets. Did you find that style guide link all right? Or wouldn't it open? Did you even find out what I thought was odd about the method I named?
I removed the unnecessary brackets if that's what you meant.
Read the assignment again and see what it says to do with the List. Also have a look at the Java™ Tutorials and see what you can find out about Lists. Note that if you create MyInteger instances or whatever the class is called, you can put them into your List.
I think the main point of this assignment is to make use of ArrayList and implement these methods through ArrayList which i haven't done before.