0

i want to passing a data from a method but in array.. some error occur like array required but double found and incompatible type.. i don't know how to do it..help me anyone...

example:

public double getFood(Date date, double AA, double BB, double CC)
{ }
// below is in main program
      cat c = new cat();

	double food = c.getFood(date,aa,bb,cc);
        String str="";
	for (int i=0;i<5;i++){
		str = food[i];
	System.out.println("cat food: " +food[i]);}

error occur when i use index in for statement. why??

Edited by peter_budo: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks)

4
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by sweetgurl
0

Your method is returning a single double, rather than a double array, and you index into an array, not a double.

0

no, the information provided should be ample for you to write your own code. It's rather trivial after all.

0

Your method is returning a single double, rather than a double array, and you index into an array, not a double.

Look at masijade's post. And you made the same mistake to another of your posts.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.