Explain?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Explain??

static int cube(int a) { return a*a*a; } And why if i use System. out.println in the method body and call it through the main there a error???And can't we use System. out.println when return type is Int??? Any why is return a*a*a; used?? is it compulsory?? and y only return is used?

24th Feb 2017, 5:31 PM
0000
4 Answers
+ 6
Could you post example code, please?
24th Feb 2017, 5:34 PM
Tashi N
Tashi N - avatar
+ 6
What you describe should work, so there are two possibilities: a) There is something else wrong with your code. b) I don't understand your question. Complete code would help to figure out, if ( (a==true) || (b==true) ). Please publish it at the playground, if possible.
24th Feb 2017, 6:07 PM
Tashi N
Tashi N - avatar
+ 2
public class Lati { public int cube(int a) { return (a*a*a); } } class Prin { public static void main (String[] args) { Lati figura1 = new Lati(); int area = figura1.cube(5); System.out.println(area); } } I have the same problem of Tashi N, i hope this code can help you to resolve the problem. if is possible post your code for more details.
24th Feb 2017, 6:58 PM
Alessio Farroni
Alessio Farroni - avatar
+ 1
its the starting part @Tashi N
24th Feb 2017, 5:35 PM
0000