So Im trying to display the location for the odd number which is 31. But it won't display the location of it.
as you see in the code. Im using bluej there's no error in compiling it's just i feel there's something missing with the location. I can't pin point what is it..
import java.util.*; import java.io.*; import java.util.Arrays; import org.apache.commons.lang.ArrayUtils; public class NumberTestingWithSearching { public static void main(String[]args) { int[] Numbers = new int[] {10,41,21,24,34,15,40,12,32,23,13,25,30,31,22,33,14,35,20,11}; List<Integer> oddarr = new ArrayList<Integer> (); List<Integer>evenarr = new ArrayList<Integer>(); int[] OddSearch = {31}; int EvenSearch = 32; //organizing Even and Odd Numbers System.out.printf("Numbers: "); for (int a: Numbers){ if ((a & 1 ) == 1){ oddarr.add(a); } else { evenarr.add(a); } System.out.printf(" "+a); } System.out.println(); System.out.println("Odd Numbers : " +oddarr); System.out.printf("Even Numbers : " +evenarr+"\n\n"); //Converting Thing Integer[] OddNumsearch = oddarr.toArray(new Integer[oddarr.size()]); int[] OddArrInt = ArrayUtils.toPrimitive(OddNumsearch); System.out.println(Arrays.toString(OddArrInt)); System.out.println(); //Linear Search Testing for (int b = 0; b < OddArrInt.length;b++){ if (OddArrInt==(OddSearch)){ System.out.println("Linear Search Location for Number 31 :"+OddArrInt); } } //Sorting Even numbers properly Collections.sort(evenarr); System.out.println("Sorted Even Numbers: "+evenarr); } }