syntax problem crating a method that returns an object (java)

Posted by David on Stack Overflow See other posts from Stack Overflow or by David
Published on 2010-03-14T17:01:50Z Indexed on 2010/03/14 17:05 UTC
Read the original article Hit count: 140

Filed under:
|
|

I'm trying to create a method that will sum two timeO objects and return a new TimeO object called sum. Here is the relevant code snippet:

public static TimeO add (TimeO t1, TimeO t2) 
    {
        TimeO sum = new TimeO ;

...

    }

When i try to compile it i get this error message:

TimeO.java:15: '(' or '[' expected
                TimeO sum = new TimeO ;
                                      ^
1 error

i cant think of any reason why it would want me to open a set of parenthasies or brackets here but its possible that i dont' quite understand the syntax. Whats going wrong here?

© Stack Overflow or respective owner

Related posts about java

Related posts about help