Solved

For loop

Posted on 2004-10-19
8
196 Views
Last Modified: 2010-03-31
What does the following for loop mean?

for (NamingEnumeration enu=attr.getAll();enu.hasMore();System.out.println("value: " + enu.next()));

Does it mean,

for (NamingEnumeration enu=attr.getAll();enu.hasMore(); )
    System.out.println("value: " + enu.next());

??
0
Comment
Question by:jtcy
  • 7
8 Comments
 
LVL 37

Expert Comment

by:zzynx
ID: 12346300
yes
0
 
LVL 37

Accepted Solution

by:
zzynx earned 20 total points
ID: 12346323
Like

   for (int i=0; i<5; System.out.println(i++));

means

   for (int i=0; i<5; i++)
        System.out.println(i);
0
 
LVL 37

Expert Comment

by:zzynx
ID: 12346332
Or
        for (int i=0; i<5;)
          System.out.println(i++);
0
 

Author Comment

by:jtcy
ID: 12346361
Why is this fine:

System.out.println("value: " + enu.next()));

but when I do:

String smth = enu.next();, it says incompatible error?, Should I do:

String smth = (String) enu.next();?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 37

Expert Comment

by:zzynx
ID: 12346389
yes
0
 
LVL 37

Expert Comment

by:zzynx
ID: 12346390
next() returns an Object, you have to cast
0
 
LVL 37

Expert Comment

by:zzynx
ID: 12346405
Writing

      System.out.println( "value: " + enu.next() );   // with two closing )'s at the end

is like writing

      System.out.println( "value: " + enu.next().toString() );
0
 
LVL 37

Expert Comment

by:zzynx
ID: 12346500
Thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now