File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Enhanced for loop question.

 
Daniel Martins
Ranch Hand
Posts: 45
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Question:

class Loopy{
public static void main (String [] args){
int [] x = {7,6,5,4,3,2,1};
//insert code here
System.out.print(y + " ");
}
}
}

Which, inserted at line 4, compiles?

Answer: for(int y: x) {

Is this answer valid for both Java 5 and 6, or only for 6?
 
Vivek Singh
Ranch Hand
Posts: 92
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use code tags....

Yes valid for both.
 
Daniel Martins
Ranch Hand
Posts: 45
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tks for your fast reply.

I will use tags next time. Tks
 
Ankit Garg
Sheriff
Posts: 9497
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tks

Please UseRealWords on javranch...
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic