Java Array for random numbers (within a certain range) then a loop to find a specific number in the array -


need figure out how declare array that's attached random number generator generates within given parameters. method find specific number in array. i've had issues number search method not being able investigate array elements. please when you've got time.

 package arraypackage;   import java.util.arrays;   import java.util.random;   public class bruteforce    {  //declare integer array 10 numbers.  int[] array = new int[10]; random randomint = new random();    //random number generator   public void shuffle() {      //int prevint=0; for(int = 0; < array.length; i++)   //for each integer in array pick random integer , place in array {     int temp = 1 + randomint.nextint(array.length);     for(int j = i; j < array.length; j++)     {         if(temp != array[j] && temp!= array[i])         {             array[i] = temp;              }          }      } }   public void displayarray() {      system.out.println(arrays.tostring(array)); } 

the exact specific homework question simple search: search number 7 in array of 10 random numbers. need declare array, use loop assign random number , use loop search number 7 in array investigating each array element.

currently duplicate check not working , need find specific number , hasn't been coded in yet.

this specific number finder thing, can't find out how integrate it

public static boolean useloop(string[] arr, string targetvalue) { (string s: arr) {     if (s.equals(targetvalue))         return true; } return false; 

}


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -