As simple as 2+2

  • 5
  • Locked
In a Java application, all the actions are performed by functions. Or more accurately, methods. In our program, a kind mentor has already implemented a method (that is, written the method's code) that can calculate the sum of two numbers. All you need to do is call this method with the arguments 2 and 2. You need to do this in the main method.
You can't complete this task, because you're not signed in.
Comments (25)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Indranil Chakraborty
Level 3 , United Kingdom
3 August, 11:22
What I wrote: mjdhehbydbuneubdhbehbduebdhheudhrhcbyfcbybbchdbjxsnjkjeudhygsdunsddjnehgcyen What it was: sum(2, 2);
MrNenavath
Level 3 , Hartford, United States
10 January, 04:08
wooh.. feeling awesome.
allisonabbate
Level 2 , Santa Fe, USA
13 August 2020, 17:38
I'm thinking in the first public static we have the method and in the second public static we have the function?
Richard
Level 2 , Columbia, United States
20 July 2020, 14:32
The knowledge needed to give a correct answer hasn't really been taught in depth yet. You may be better off coming back to this one down the road after you have more training for it to make sense. I think the purpose of this task is just to get you thinking and prepare you for what's coming.
Thomas
Level 7 , Scottsdale, United States
16 September, 05:00
THIS ! --- Code Gym drops some things out of the sky with no background reading at all ! It's their method. It's part of the programming struggle. Go with it !
Gzzui892
Level 6 , Germany
10 June 2020, 02:37
This task is an epic one, thus, it is normal if one's having a misunderstanding since further knowledge is needed to comprehend what is actually happening. For the reference, I have come back to this task after almost finishing level 2. And I can understand what the task is all about. My level 1 could not understand anything. So for anybody out there, who is not yet ready either to search new things or don't have the knowledge yet, I would suggest to skip this task and come back later.
Andrew Henry
Level 2 , Oklahoma City, United States
18 November 2019, 19:13
• The program should display the sum of 2 and 2. • The main method should call the sum method with the arguments 2 and 2. • The main method should not call a screen output method. • Don't change the sum method. In order to display the sum, you'd need to use println, or another screen output method. But you also should not call a screen output method. Conflicting requirements in the final task.
Colin McKay
Level 2 , Buffalo, United States
11 August 2019, 00:31
sum(2, 2); all you have to do (I used a hint) I guess to call a new method you just type the name of it with parentheses and the arguments inside of them
MD Alice
Level 3 , Petah Tikva, Israel
16 June, 20:58
amazing
Thomas
Level 7 , Scottsdale, United States
16 September, 05:08
THIS ! Kinda like hoisting in JavaScript ? ... where the invoke / call to launch the function is way above the method function definition. It's a total trip for new coders for sure --- hang in there -- totally fundamental to JAVA and all programming. It's good to see that line x line procedural coding from the stone age has evolved where-by the software build is so fast into memory that it can see all the code above / below ... where ever. My 2 cents.
Rosita
Level 2 , Oceanside, United States
26 June 2019, 19:38
I am not seeing in the lesson where is tells you how to call a method in the same class. Is it in a previous lesson?
Matvey Dvorkin
Level 3 , Kiev, Ukraine
28 April 2019, 16:30
confusing task. :(
E. Venkataswamy
Level 3 , Trichur, India
12 January 2019, 17:28
bit dificult