Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Going crazy

  1. #1
    Junior Member
    Join Date
    Sep 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Going crazy

    I think I have been looking at it too long. I have this simple code but cannot see what is wrong with it. I think my error is in the static main but am absolutely stuck. Thank you for any help.

    public class Triangle
    {
    public static void main(String[] args)

    private double base;
    private double height;

    public Triangle ()
    {
    base = 1;
    height = 1;
    }
    public Triangle (double b, double h)
    {
    base = b;
    height = h;
    }
    public double computeArea()
    {
    double area;
    area = .5 * base * height;
    return area;
    }

    }


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Going crazy

    Please post the full text of the error messages.

    Please Edit your post and wrap your code with
    [code=java]
    <YOUR CODE HERE>
    [/code]
    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 140 Times in 135 Posts

    Default Re: Going crazy

    Since you're not using an IDE, I suggest that you start your program creation with the most bare of program "skeletons", say nothing but the class name and the main method and nothing more. Compile this code to make sure it works, and then every time you add a line or two of code, compile the code to check for errors. Don't add any new lines until you've fixed all errors and your current code compiles well. This will prevent you from adding more code to an already broken program.

Similar Threads

  1. its crazy
    By chonch in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 17th, 2011, 02:26 PM
  2. Very basic program but its making me crazy
    By craig carl in forum What's Wrong With My Code?
    Replies: 5
    Last Post: February 2nd, 2011, 03:16 PM
  3. I'm sure it is really simple but it is driving me crazy
    By Ademske in forum AWT / Java Swing
    Replies: 2
    Last Post: January 17th, 2011, 07:41 AM
  4. Crazy array
    By javapenguin in forum What's Wrong With My Code?
    Replies: 18
    Last Post: June 26th, 2010, 03:02 AM
  5. [SOLVED] NullPointerException in Poker's program
    By dean_martin in forum Exceptions
    Replies: 10
    Last Post: April 21st, 2009, 06:40 AM