W
W
Who_Is_Who2018-10-05 18:47:39
Java
Who_Is_Who, 2018-10-05 18:47:39

For each element in the array...?

There is a combination with a loop: Translated as "Repeat for each element in the orange array". There is in another method , where Number- int is a variable, I get it in another method using Next, I would like to do "For each element in the array, we perform a post-increment operator on the variable z" I get this: but an error occurs with The first question: how to create it correctly cycle in this case? The second question: what is the name of this cycle in the scientific language: ? PS: in the debug logs the values ​​are:
for( int y: orange)
args.putInt(S_NUMBER, Number);getArguments().getInt(S_NUMBER)
for(int c : getArguments().getInt(S_NUMBER))
';' expected
for( : массив)
getArguments().getInt(S_NUMBER)

getArguments().getInt(S_NUMBER): 1 
getArguments().getInt(S_NUMBER): 2

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Cheremisin, 2018-10-05
@leahch

First, install some development environment for yourself, idea or eclipse or netbeans.
Secondly, the cycle must be of the Collection or Iterable types. Accordingly

for(Object obj : getArguments()) {
    int с = (MyArgumentType)obj.getInt(S_NUMBER));
}

Where the type obj will be substituted for you by your development environment.

C
Cheypnow, 2018-10-06
@Cheypnow

It's called foreach.
The problem is that in getArguments().getInt(S_NUMBER)you just get a number and try to iterate over it, and the loop must go through an array or collection.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question