H
H
Horoko2015-04-23 21:15:52
Java
Horoko, 2015-04-23 21:15:52

How does a for loop work in Java?

Subject. As far as I know, this is a new for(:){} construct. Explain the logic of its work please. There is a code:

List<User> users = dab.getAllUsers();
        for (User cn : users) {
            String log = "Id: "+cn.getID()+" ,Name: " + cn.getLogin() + " ,Phone: " + cn.getPassword();
        }

Answer the question

In order to leave comments, you need to log in

3 answer(s)
K
Kirill Olenev, 2015-04-23
@agent10

New?) This is a well known old one)
docs.oracle.com/javase/specs/jls/se7/html/jls-14.h...

V
Vladimir Abramov, 2015-04-23
@kivsiak

Lord, well, this is the basics at all.
Suggest free online Java courses - at least learn a little first.

S
Sergey, 2015-04-23
Protko @Fesor

This is analogous to forEach or for in.
That is, "for each element (User cn) in the list (users) execute ...."

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question