473,385 Members | 1,402 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Weird for() statement

44
Hi everyone! Does anyone can explain the ":" in the for() statement below?

Example:

Integer[] integerArray = { 1, 2, 3, 4, 5};

for ( Integer element : integerArray )
System.out.printf( "%s ", element );

Thanks for the attention.
Aug 28 '06 #1
2 1341
PLA
44
Hi everyone! Does anyone can explain the ":" in the for() statement below?

Example:

Integer[] integerArray = { 1, 2, 3, 4, 5};

for ( Integer element : integerArray )
System.out.printf( "%s ", element );

Thanks for the attention.
It's new in Java 5.0, you have the ability to write 'simple' for statement when you iterate over an array or a collection, ':' means 'in' , you should read your line

for each integer element in integerArray do

More info here
Aug 28 '06 #2
zeny
44
Thanks for the explanation PLA, this is indeed a very cool new feature of Java 5.

Java rules!
Aug 29 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Matthew Paterson | last post by:
Ok - has anyone ever had this happen before? I have a SQL Insert statement. When I build the SQL and execute it in PHP I get the following error: Warning: (null)(): Invoke() failed: Exception...
11
by: HelLind | last post by:
Hello people, I am having a weird error and don't know what term to search in google. Sorry to bother. There is data in my field "M_BIO" When I run this code...
2
by: jwbeaty | last post by:
Here's a weird one. I'm running SQL Server 7 and when I run a backup something weird happens. When I perform the backup via Enterprise Manager by right clicking on the database I want to...
7
by: Jon Combe | last post by:
I have created the following test SQL code to illustrate a real problem I have with some SQL code. CREATE TABLE JCTable ( CustomerName varchar(50) ) ALTER TABLE JCTable ADD CustomerNo int...
3
by: Val | last post by:
In vc7 (studio 2002), when I try to debug the first "if" statement, the IDE jumps to the next valid line and evaluates it even if the if-statement is false. What is going on? if(...
7
by: dhnriverside | last post by:
Hiya Right, I'm trying to make an A-Z page for my site. It starts on A, with a row of 26 letters along the top that you can click on. Fine so far. Now I've come to pull the data in from the...
2
by: WisTex | last post by:
I've come across a very weird problem. Virtual includes work on all my ASP pages on the entire website, including those in subdirectories, yet they won't work on a particular page I created, even...
13
by: jimjim | last post by:
Hello all, I ve come across the following code fragment and I was wondering why is the copy ctr called on return (rather than just returning the string statement obj. TIA string...
5
by: Frederick Dean | last post by:
Hi,guys! I'm reading Stephen Dewhurst's book "C++ Gotchas"£¬in gothca #7, I meet a weird case: bool Postorder::next() { switch (pc) case START: while (true) if (!child()) { pc = LEAF; return...
11
by: ssecorp | last post by:
I am never redefining the or reassigning the list when using validate but since it spits the modified list back out that somehow means that the modified list is part of the environment and not the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.