Question:
How do I fix these error message in my java code?
anonymous
2009-05-04 11:19:09 UTC
p8.java:55: countArray1(int[],int) in p8 cannot be applied to (int[])
System.out.printf("10 occurs %d times\n", countArray1(nums));
^
1 error

***** in this code *********

System.out.printf("10 occurs %d times\n", countArray1(nums));

//returns how many times a number occurs in the above statements
public static int countArray1(int temp[], int item)
{

int count = 0;

for (int x=0; x {
if (temp[10] == item);
else
count = count + 1;
}
return count;
}//countarray1

//i am trying to count how many a numer occurs in a array of 8 numbers. it could be very possible that i don't have all the info needed for you to fix the problem. if so, i'm sorry.
Four answers:
anonymous
2009-05-04 11:24:54 UTC
I don't do Java but I think the problem is obvious. countArray takes two parameters but you are only giving it one.
?
2016-10-19 15:48:16 UTC
study what the errors says. It says your code has a function call that may throw an uncaught exception. you may desire to characteristic a try/seize fact to handle the exception. i think that the exception is predicted from a sort of two strains: FileWriter fw = new FileWriter("outputFile.txt"); PrintWriter pw = new PrintWriter(fw); It says 'line 27', so examine which of those is line 27 on your document. encompass it with a try/seize fact. you do no longer truthfully could desire to do something interior the seize block to determine that this technique to convey mutually miraculous, yet you do could desire to have the try/seize fact in place.
anonymous
2009-05-04 11:29:33 UTC
lover dude is right, countArray1(int[] temp, int item) takes in and array and an integer but whey you call it you are only giving it an array (nums).
anonymous
2009-05-06 19:57:42 UTC
hello Lee,

I think this will help you with your issue.

http://www.pc-error-repair.org/error-repair/error-10.html

Good Luck,

Anna


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...