Foreach not applicable to expression type - why am I getting this?
-
public static double[] adjustFrequency(double[] samples, double factor) { int newSamplesIndex = 0; double samplesIndex = 0; double[] newSamples = new double[samples.length]; for (int n : newSamplesIndex) if (n < newSamples.length-1) { newSamples[newSamplesIndex] = samples[(int)samplesIndex]; samplesIndex =+ factor; } return newSamples; } This method is part of a compsci assignment that does a series of operations on arrays, I need to use a foreach loop but I keep getting the error "Foreach not applicable to expression type". Any thoughts?
-
Answer:
your calling foreach on a regular int. proper use for(int n : intarray) My best guess is you wanted to do something like for(double d : newSamples) { if (d ... etc }
Sansom at Yahoo! Answers Visit the source
Related Q & A:
- Why am I getting an "Expected Identifier" error?Best solution by Stack Overflow
- Why am i getting an ArgumentOutOfRangeException?Best solution by Stack Overflow
- Why am I getting error unwrapping Optional if it has a value?Best solution by Stack Overflow
- Why am I getting error on page?Best solution by Yahoo! Answers
- Why am I getting a Yahoo Mail Error?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.