Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Just starting to learn Java, illeagal start of expression error

807569Sep 7 2006 — edited Sep 8 2006
I'm trying to compile this code so i can test it out but i get this error

Angle.java:18: illegal start of expression
public Angle ( double a , int units )
^
1 error

This is my code so far.
public class Angle
{
  private double rads;
    {
       final static public int RADIANS = 0, Degrees = 1;
       public Angle ( double a , int units )
       if ( units == RADIANS) { setRadians(a); }
       else if ( units == DEGREES) { setDegrees(a); }
       else throw new RuntimeException( "Bad Units: " + units );
    }
  public double getRadians() { return radians; }
  public void setRadians( double rads ) { radians = rads; }
  public String toString() { return getRadians() + " Radians"; }
  public double getDegrees() { return radians * 57.29577951; }
  public void setDegrees( double degs ) { radians = degs * 0.0174532925; }
  public String toString() { return getDegrees() + " Degrees"; }
}
I know its more than likely a syntax thing that im messing up although i feel like it could easily be something much bigger, any help to get me past this would be greatly appreciated.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 6 2006
Added on Sep 7 2006
4 comments
93 views