menu
QAmmunity.org
Login
Register
My account
Edit my Profile
Private messages
My favorites
Register
Ask a Question
Questions
Unanswered
Tags
Categories
Ask a Question
Assume the method dosomething has been defined as follows: public static void dosomething (int[] values, int p1, int p2) { int temp = values[p1]; values[p1] = values[p2]; values[p2] = temp; } what does
asked
Mar 22, 2019
63.8k
views
1
vote
Assume the method dosomething has been defined as follows: public static void dosomething (int[] values, int p1, int p2) { int temp = values[p1]; values[p1] = values[p2]; values[p2] = temp; } what does the method do?3
Mathematics
college
Sam Dozor
asked
by
Sam Dozor
6.3k
points
answer
comment
share this
share
0 Comments
Please
log in
or
register
to add a comment.
Please
log in
or
register
to answer this question.
1
Answer
1
vote
First step is to analyze input and output variables:
INPUT:
list of integers with name "values"
integer with name "p1"
integer with name "p2"
OUTPUT:
there is no output variable as in declaration of a method there is void
ANALYSIS:
"
int temp = values[p1]"
this line creates variable "temp" which is integer. then this line goes to the list "values" and takes value that is at position "p1" and stores it into variable "temp"
"
values[p1] = values[p2]"
this line
goes to the list "values" and takes value that is at position "p2" and stores it into variable that is at position "p1"
"
values[p2] = temp"
this line takes value of the variable "temp" and stores it into list values at position "p2"
Short explanation:
this code replaces values of the list at between positions p1 and p2
Maxdangelo
answered
Mar 27, 2019
by
Maxdangelo
6.0k
points
ask related question
comment
share this
0 Comments
Please
log in
or
register
to add a comment.
Ask a Question
Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.
6.5m
questions
8.7m
answers
Other Questions
What is the least common denominator of the four fractions 20 7/10 20 3/4 18 9/10 20 18/25
What is 0.12 expressed as a fraction in simplest form
Solve using square root or factoring method plz help!!!!.....must click on pic to see the whole problem
What is the initial value and what does it represent? $4, the cost per item $4, the cost of the catalog $6, the cost per item $6, the cost of the catalog?
What is distributive property ?
Twitter
WhatsApp
Facebook
Reddit
LinkedIn
Email
Link Copied!
Copy
Search QAmmunity.org