+ 2

How can i call it ? Sum method see code in description

public class Program { public static void main(String[] args) { double a = 42.571; int b = (int) a; // how can call it sum((int) a , b); } // without changing it public void sum(int c, int d){ System.out.println(c+d); } }

26th Oct 2019, 8:57 AM
VikaSh YadaV
VikaSh YadaV - avatar
3 ответов
+ 2
Use 'static' . I have a request: When you post same code examples please use the plus Symbol (+) to add your code in your post. Thank you. Regards kiuziu
26th Oct 2019, 9:56 AM
Kiuziu 💘 Berlin
Kiuziu 💘 Berlin - avatar
+ 1
you need to change the function to static public void sum(int c, int d){ System.out.println(c+d); }
26th Oct 2019, 9:02 AM
Tomer Sim
Tomer Sim - avatar
+ 1
Thanks it seem very easy
26th Oct 2019, 10:00 AM
VikaSh YadaV
VikaSh YadaV - avatar