• 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:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Enhanced for loop

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using enhanced for loop in my java program and have j2sdk 1.5.0 installed, but still the compiler gives error at the loop statement. Syantax is also correct. Do I need to update the version??

Thanks!!
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch!

If Java 1.5 is properly installed, then it should be working fine. Why don't you post your code and have some more eyes check the syntax?
 
author & internet detective
Posts: 42056
926
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Smart Aquarian",
We're pleased to have you here with us at JavaRanch, but there are a few rules that need to be followed, and one is that proper names are required. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks,
Jeanne
artender
 
Namit Puri
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

//compiler giving error at the enhanced for loop


EDIT by mw: Added Code Tags to original poster's indentation.
[ August 20, 2006: Message edited by: marc weber ]
 
marc weber
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay, your code compiles fine for me, so let's move on to your installation of Java 1.5. What do you get when you type "javac -version" at the command line? (Without a file name, you'll get a long error message, but it should start with the version.)

...javac -version
javac 1.5.0_06
javac: no source files...

My guess is that you're on a Windows machine, and you didn't adjust your PATH variable properly. See Step 5 of these installation instructions for Windows. BUT note that the system checks the PATH variable from left to right, looking for a path that will work. So if you have a path for a prior version of Java listed first, then it will use the prior version.
 
Namit Puri
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, I am working on Windows XP and running the javac -version command returns:
javac 1.5.0-beta
javac: no source files

The step 2 of installation notes recommends to uninstall any beta versions.
What do you reckon?

The path is also set as C:\j2sdk1.5.0\bin;

Thanks!
 
marc weber
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, clear out any beta versions. (I don't know whether that alone will work, or whether you will need to reinstall the regular version after that.)

Which update of 1.5 are you installing? I think the current version for Windows is Update 8 -- that is, 1.5.0_08.
[ August 20, 2006: Message edited by: marc weber ]
 
Ranch Hand
Posts: 1847
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
not all of the betas included the enhanced for loop.
Not quite sure at which stage it was included.

Indeed you should install the latest production release (_08 by now) and get rid of that beta.
 
Namit Puri
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yup, got it working. Just updated with the latest version.

Thanks to everyone!!
 
Seriously? That's what you're going with? I prefer this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic