Hello great programmers at this website. Hopefully your day has been good so far. I was wondering if you could help me with some Java errors related to the header of my program that I am doing for an assignment. Thank you millions for your help. Here is the code:

import java.Math.*;
import java.swing.JOptionPane;

public class EqTri
{ 
private double sideLength;
private String identifier;
{
public EqTri(double x,String s)
{
sideLength= x;
identifier=s;

}
public setsideLength(double x)
{
x= sideLength;

}
public setIdentifier(String s)
{
s= identifier;

}
public double getsideLength()
{
return x;
}
public String getIdentifier()
{
return s;

}
public double getPerimeter()
{
return 3*s;
}
public double getArea()
{
return (Math.sqrt(3)/4)*a*a;

}
}

Here are the errors that came, for your convenience:

EqTri.java:9: illegal start of expression
public EqTri(double x,String s)
^
EqTri.java:9: '.class' expected
public EqTri(double x,String s)
                    ^
EqTri.java:9: ';' expected
public EqTri(double x,String s)
                     ^
EqTri.java:9: ';' expected
public EqTri(double x,String s)
                              ^
EqTri.java:15: illegal start of expression
public setsideLength(double x)
^
EqTri.java:15: '.class' expected
public setsideLength(double x)
                            ^
EqTri.java:15: ';' expected
public setsideLength(double x)
                             ^
EqTri.java:20: illegal start of expression
public setIdentifier(String s)
^
EqTri.java:20: ')' expected
public setIdentifier(String s)
                           ^
EqTri.java:20: illegal start of expression
public setIdentifier(String s)
                             ^
EqTri.java:20: ';' expected
public setIdentifier(String s)

Thank you again.

I think lots of your problems are stemming from an unnecessary curly brace on line 8.

Some padding helps identify the errors.
Try something along the lines of the following:

import java.Math.*;
import java.swing.JOptionPane;
public class EqTri {
    private double sideLength;
    private String identifier;
    public EqTri(double x,String s) {
        sideLength = x;
        identifier = s;
        //note here "s" is not global to the class nor static to the project.
        }
    public setsideLength(double x) {
        x = sideLength;
        }
    public setIdentifier(String s) {
        s = identifier;
        }
    public double getsideLength() {
        //x is undefined. Null Pointer Exception
        return x;
    }
    public String getIdentifier() {
        //s is undefined. Null Pointer Exception
        return s;
    }
    public double getPerimeter() {
        //s is undefined. Null Pointer Exception
        return 3*s;
    }
    public double getArea() {
        //a is undefined. Null Pointer Exception
        return (Math.sqrt(3)/4)*a*a;
    }
}
public double getsideLength() {
        //x is undefined. Null Pointer Exception
        return x;
    }

what do you mean, NullPointerException? this won't compile, how do you expect a RuntimeException on this ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.