public class adding

public class adding 
{
    public static void main(string[] args){
      {  
        int a=1;
        int b=2;
        sum c=a+b;
        system.out.println c;(sum c)->

    }
}

help illegal start of expressions

lines 3,4 you have two {

Also, I think that line 8 should just be system.out.println(c);
The compiler will probably complain about the (sum c)-> - it is non-terminated (no semicolon) and there isn't some value or method that the "pointer-to" operator references.

This isn't what's causing your syntax error, but Java doesn't have a type named sum nor do you define one anywhere in your prorgram (unless you defined it in a different file that you didn't show), so sum c is a type error (both on line 7 and line 8).

The compiler will probably complain about the (sum c)-> - it is non-terminated (no semicolon) and there isn't some value or method that the "pointer-to" operator references.

Java doesn't have pointers - -> is only used for lambdas (which would make (sum c) the argument list. But you're definitely right that a ; is missing. And there needs to be a function body after the ->. Also it makes no sense to have a lambda there.

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.