189k views
4 votes
Write and compile a java code to add 18+6?

1 Answer

6 votes

Answer:

public class testing

{

public static void main(String[] args)

{

int x = 18;

int y = 6;

System.out.println(addNumbers(x, y));

}

public static int addNumbers(int a, int b)

{

return a + b;

}

}

User Skink
by
4.9k points