+Silver Tech created by SyringeX of the IF Skin Zone



Skin selector:

 

 help with java
pfrimmdog
Posted: Nov 5 2004, 12:00 AM


Newbie


Group: Members
Posts: 3
Member No.: 5
Joined: 24-October 04



I'm really new to java and I am using the NetBeans program to write Java programs. I've already written 2 really easy program, but for some reason this one won't work. It's straight out of a programming book. This is what the netbeans is telling me:

project1/ifsample.java [17:1] '{' expected
class project1.ifsample {{
^
1 error
Errors compiling ifsample.









/*
* ifsample.java
*
* Created on November 3, 2004, 6:39 PM
*/

package project1;

/**
*
* @author wayne
*/
public class ifsample {


}
class project1.ifsample {{
public static void main(String args[]) {
int x, y;
x = 10;
y = 20;
if (x< y) System.out.println("x is less than y") ;
x = x * 2;
if (x == y) System.out.println("x is equal to y") ;
x = x * 2;
if (x> y) System.out.println("x is now greater than y") ;
if (x == y) System.out.println("you won't see this") ;

}
}}}
Top
Cap'n Refsmmat
Posted: Nov 5 2004, 01:51 AM


To Protect and Sever


Group: Admin
Posts: 142
Member No.: 1
Joined: 24-October 04



CODE
/*
* ifsample.java
*
* Created on November 3, 2004, 6:39 PM
*/

package project1;

/**
*
* @author  wayne
*/
public class ifsample {
   
   
}   //What is this class for? I see no reason.
class  project1.ifsample {{  //Two brackets? Why?
   public static void main(String args[]) {
       int x, y;
       x = 10;
       y = 20;
       if (x< y) System.out.println("x is less than y");
       x = x * 2;
       if (x == y) System.out.println("x is equal to y");
       x = x * 2;
       if (x> y) System.out.println("x is now greater than y");
       if (x == y) System.out.println("you won't see this");
       
   }
}}} //Too many brackets here, that's the problem!

Read my comments there.
Top
Cap'n Refsmmat
Posted: Nov 5 2004, 02:07 AM


To Protect and Sever


Group: Admin
Posts: 142
Member No.: 1
Joined: 24-October 04



Moved to the new Java forum.
Top


Topic Options



Hosted for free by InvisionFree (Terms of Use: Updated 7/7/05) | Powered by Invision Power Board v1.3 Final © 2003 IPS, Inc.
Page creation time: 0.0765 seconds | Archive
The best new computer discussion forums on the net! Join now!
And while you're at it, join www.scienceforums.net, the best science discussion on the internet!
Skin by SyringeX of the IFSkinZone.