525,319 views
25 votes
25 votes
Write and compile a java code to add 18+6?

User Acenturyandabit
by
2.7k points

1 Answer

20 votes
20 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 Espinchi
by
2.8k points