# Problems with java - illegal start of expression



## Chrift (Jan 12, 2009)

Hey there everyone, I am doing my second year at uni doing buiness information technology and i have just started my first assignment of 2009 and seem to have forgotten everything over the christmas holidays!

I have this code:


```
import java.io.*;

class NewDate
{
    public static void main(String[] args) throws IOException
    {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        
        //attributes
        int day, month, year;
        String tempstore;
        
        //dcm
        public NewDate()
        {
            day = 1;
            month = 1;
            year = 1900;
            
        }
        
        //constructor method
        public NewDate(int dayIn, int monthIn, int yearIn)
        {
            day = dayIn;
            month = monthIn;
            year = yearIn;
        }
        
        public void setDate(int dayIn)
        {
            day = dayIn;
        }
        
        public void setMonth(int dayIn, int monthIn)
        {
            day = dayIn;
            month = monthIn;
        }
        
        public void setYear(int dayIn, int monthIn, int yearIn)
        {
            day = dayIn;
            month = monthIn;
            year = yearIn;
        }
        
        public int getDay()
        {
            return day;
        }
        
        public int getMonth()
        {
            return month;
        }
        
        public int getYear()
        {
            return year;
        }
        
        public boolean isLeapYear(int yearIn)
        {
            if (yearin % 4 == 0)
            {
                return = true;
            }
            else
            {
                return = false;
            }
        }
        
    }
```
But it throws an error when it gets to "public NewDate()".

It does not do this if i remove the second set of curly brackets and the input output stuff, why does it do this? If i remove the newdate bit it just throws the error about the first part of the next bit. HELP! Getting annoyed!

Sorry if my explanations arent very good lol!

Thank You!


----------



## Jprichard (Jun 4, 2007)

I looked over your code, and I made changes as to what I think was right. I do not understand the point of your main method, but you were'nt closing it. You should download an IDE, I use Netbeans. Picked your errors up immediatly, very nice, eliminates some of the frustration and difficulty. Cheers.

```
import java.io.*;

class NewDate {
    //attributes

    int day, month, year;
    String tempstore;

    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(
                new InputStreamReader(System.in));
    }

    //dcm
    public NewDate() {
        day = 1;
        month = 1;
        year = 1900;

    }

    //constructor method
    public NewDate(int dayIn, int monthIn, int yearIn) {
        day = dayIn;
        month = monthIn;
        year = yearIn;
    }

    public void setDate(int dayIn) {
        day = dayIn;
    }

    public void setMonth(int dayIn, int monthIn) {
        day = dayIn;
        month = monthIn;
    }

    public void setYear(int dayIn, int monthIn, int yearIn) {
        day = dayIn;
        month = monthIn;
        year = yearIn;
    }

    public int getDay() {
        return day;
    }

    public int getMonth() {
        return month;
    }

    public int getYear() {
        return year;
    }

    public boolean isLeapYear(int yearIn) {
        if (year % 4 == 0) {
            return true;
        } else {
            return false;
        }
    }
}
```


----------



## brett30 (Jan 13, 2009)

This code isn't going to do anything at all though? Except make a buffered reader. Is there more to this code? If there is... the best coding would be to break the main argument out into a different separate class of its own and add an instance of the NewDate class ....and depending on what the application needs to do is how to determine what needs to go into the main method.


----------



## Chrift (Jan 12, 2009)

Ah cheers mate, have downloaded netbeans but seems a bit complicated for me!
Am using blueJ at the moment but will try and convert over to netbeans as it does seem much more feature packed!



brett30 said:


> This code isn't going to do anything at all though? Except make a buffered reader. Is there more to this code? If there is... the best coding would be to break the main argument out into a different separate class of its own and add an instance of the NewDate class ....and depending on what the application needs to do is how to determine what needs to go into the main method.


Yes its just what i threw together there is a lot more to it and yes it will be broken into different classes.


----------



## brett30 (Jan 13, 2009)

You should try eclipse it has as many features as netbeans but is not as complicated.


----------



## Chrift (Jan 12, 2009)

Cheers mate will check that out!


----------



## Jprichard (Jun 4, 2007)

I just started out using Netbeans, so I'm comfortable with it, I suppose its all up to choice. So did you solve your problem?


----------



## best_links (Jan 18, 2009)

i think you must have to specify the return type of the method newdate().


----------

