Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Java in General
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Tim Cooke
Campbell Ritchie
Ron McLeod
Junilu Lacar
Liutauras Vilda
Sheriffs:
Paul Clapham
Jeanne Boyarsky
Henry Wong
Saloon Keepers:
Tim Moores
Tim Holloway
Stephan van Hulst
Piet Souris
Carey Brown
Bartenders:
Jesse Duncan
Frits Walraven
Mikalai Zaikin
Forum:
Java in General
for loop
Ramm Kummar
Greenhorn
Posts: 26
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Could anyone explian me about the for loop below(commented one)
import java.util.*; class SetTest { public static void main(String[] args) { boolean[] ba = new boolean[5]; Set s = new HashSet(); ba[0] = s.add("a"); ba[1] = s.add(new Integer(42)); ba[2] = s.add("b"); ba[3] = s.add("a"); ba[4] = s.add(new Object()); for(int x=0; x<ba.length; x++) System.out.print(ba[x] + " "); System.out.println("\n"); for(Object o : s) // for loop is confusing here System.out.print(o + " "); } }
Sagar Rohankar
Ranch Hand
Posts: 2908
1
I like...
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Whats confusing you , a syntax or logic. ?
If you don't know anything about for..each loo, have look at this
tutorial.
[LEARNING bLOG]
|
[Freelance Web Designer]
|
[and "Rohan" is part of my surname]
Don't get me started about those stupid
light bulbs
.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Does equal() not have to be overridden
is LinkedHashSet ordered?
using Sets
Problem faced in using hashset(comparison of equal elements)
Set question
More...