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??

Recommended Answers

All 5 Replies

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

can u give an example??

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

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.

ok..i will try..thanks for answering..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.