yeah... i got the greeting thing...

according to the book i have...

for(String g : greeting)
is a new JDK 5.0 feature ....

rather than the traditional for(i=0...etc..)


On Tue, 21 Dec 2004 08:40:07 -0800, Spike <[EMAIL PROTECTED]> wrote:
> You have a couple of problems with the syntax of your code:
> 
> 1. You need to declare the greeting array as an array of strings before
> using it:
> 
> String[] greeting = new String[2]
> 
> 2. The syntax of your for loop is invalid. I'd do it like this:
> 
> 
> for (int i=0;i<greeting.length ; i++) {
>    System.out.println(greeting[i]);
> }
> 
> So the whole thing would be:
> 
> *****************************
> 
> public class Welcome {
> 
>         public static void main(String[] args) {
>                 String[] greeting = new String[2]
>                 greeting[0] = "Welcome";
>                 greeting[1] = "howdy";
> 
>                 for (int i=0;i<greeting.length ; i++)
>                         System.out.println(greeting[i]);
>         }
> }
> ****************************
> 
> Spike
> 
> Critter wrote:
> > I am just trying to build a simple class file using eclipse.. but I
> > keep getting syntax errors..
> >
> > public class Welcome {
> >
> >       public static void main(String[] args) {
> >               greeting[0] = "Welcome";
> >               greeting[1] = "howdy";
> >
> >               for (String g : greeting)
> >                       System.out.println(g);
> >       }
> > }
> >
> > Severity      Description     Resource        In Folder       Location      
> >   Creation Time
> > 2     Syntax error on token ")", invalid
> > AssignmentOperator    Welcome.java    Welcome line 20 December 21, 2004
> > 10:51:12 AM
> > 2     Syntax error on token(s), misplaced
> > construct(s)  Welcome.java    Welcome line 20 December 21, 2004 10:51:12
> > AM
> >
> > i am thinking it has to do with maybe eclipse using the wrong jre...
> > but i am not sure.. I've pointed eclipse to use the newer jdk.. (i
> > think..) any suggestions?
> 
> --
> 
> --------------------------------------------
> Stephen Milligan
> Code poet for hire
> http://www.spike.org.uk
> 
> Do you cfeclipse? http://cfeclipse.tigris.org
> 
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Special thanks to the CF Community Suite Silver Sponsor - New Atlanta
http://www.newatlanta.com

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:188386
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to