java - remove and print prime numbers in an array -


I have an assignment for the class and the purpose is to take an array and it is run through a method The array will print out the reverse order, then test it to run through the second method, if the number is prime then print the reverse order array without the main numbers. I can fix the reverse order part, I'm getting bogged down in part of the main numbers:

public class driver {public static zero main (string [] args) {// CTORs int [] Mayor = {10, 8, 7, 14, 22, 11}; Int [] myArray2 = new int [7]; // METHOD Calling Maire = Reverse Order (6, Mayre); Mayré = Primychic (Myere, 6); For (int i = 0; i & lt; myArray2.length; i ++) System.out.println (myArray2 [i] + ""); } // MAIN / * -------------------- ARRE PRIEST TEST --------------------- * / Private static int [] Primchock (Int [] Mayor, int number) {// Prime Boolean Prime = true; Int [] myArray2 = new int [10]; // test all components of an array (int i = num + 1; i> = 0; i ++) {if (num% i> 0) {prime = false; System Arrayopyi (Myere, 0, Mayer 2, 0, 4); Return myArray2; }} MyArray2; } / ISPRIME REMOVE} // CLOSE

My output is as follows:

  11 22 14 7 8 10 0 0 0 0 0  

I think that is actually cut off because it is the first assignment after a long break, so any guidance or help would be appreciated.

myArray2 is defined and never filled with values So every element is 0.

I think

 for  (int i = 0; i & lt; myArray2.length; i ++)  

 for  (int i = 0; i & lt; myArray.length; i ++)  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -