Hi im trying to make a program that passes an array to a method. the method then finds the smallest number in the array and passes that number back to the main where its printed out. I am getting an error saying: "error: number cannot be resolved to a variable". I am using drjava. here is my code.
Code:
import java.util.*;
public class homeWorkTwo{
public static void main(String[] args)
{
int[] arrayA;
arrayA = new int[10];
arrayA[0]=7;
arrayA[1]=5;
arrayA[2]=8;
arrayA[3]=9;
arrayA[4]=2;
arrayA[5]=10;
arrayA[6]=11;
arrayA[7]=1;
int lowestNumber = find_sum(number);
System.out.print("The smallest number is: "+lowestNumber);
}
public static int find_sum(int [ ] arrayB){
int isItSmaller=0;
int small=0;
System.out.println("poop");
for(int i=0;i<=7;i++){
isItSmaller=arrayB[i];
if(small<isItSmaller){}
else
small=isItSmaller;
}
System.out.print(small);
return small;
}
}
omg your amazing! how the heck did u figure that out so quick?! i must really suck at programming lol. can you help me with one more thing? it only prints 0... based on what i have entered the lowest number is 1... any ideas?
And the error message *told* you the problem. You just need to learn how to read error messages.
Quote:
"error: number cannot be resolved to a variable".
In other words, you don't have any variable that is named number. Okay, so then I look at your code and it's obvious what variable should be there, instead.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.