So I solved this but I don't understand how the program draws the radius variable since nowhere in the code do we write:
radius = 5
Can somebody explain how our script draws radius to equal 5 without us assigning it?
I solved this but I don't understand how, can somebody explain please.
Under discussion
Comments (5)
- Popular
- New
- Old
You must be signed in to leave a comment
Travis Crawford
27 September 2019, 16:13
The method printCircleCircumference(int radius) already has the parameter "radius" as a placeholder. All we have to do is create a variable for "pi" and a variable for "c" with the formula and then display it to the screen.
0
EDWIN DEEPAK S
11 August 2019, 02:26
Its because we are passing the value 5 when we call printCircleCircumference method in main method.
for example:
public void main (String args[]){
name(5); //we are passing the value 5 when calling name method.
}
public static void name(int a){ //5 is assigned the value a
System.out.println(a); //prints 5
}
HOPE THIS HELPS!(The double slash is not part of the code. It is for your understanding)
0
Anthony Chalk
10 August 2019, 22:50
because the radius integer is declared in the method i.e. "public static void printCircleCircumference(int radius) ", you can call the method for any value.
0
Brandon Nicolle
11 August 2019, 01:14
Yes but how does it know the radius is 5?
0
Petr Svitil
6 November 2019, 22:11
But when you call for radius, how is that connected to the main method?
Is it because its the only value declared so when you call for some value, this is a default?
Thanks!
0