Top Posters
Since Sunday
5
k
4
c
4
4
M
3
t
3
i
3
B
3
k
3
m
3
c
3
o
3
New Topic  
Famwam Famwam
wrote...
Posts: 456
4 years ago
Do the following two programs produce the same result?

Program I:
public class Test {
public static void main(String[] args) {
int[] list = {1, 2, 3, 4, 5};
reverse(list);
for (int i = 0; i < list.length; i++)
System.out.print(list[i] + " ");
}

public static void reverse(int[] list) {
int[] newList = new int[list.length];
for (int i = 0; i < list.length; i++)
newList[i] = list[list.length - 1 - i];
list = newList;
}
}

Program II:
public class Test {
public static void main(String[] args) {
int[] oldList = {1, 2, 3, 4, 5};
reverse(oldList);
for (int i = 0; i < oldList.length; i++)
System.out.print(oldList[i] + " ");
}

public static void reverse(int[] list) {
int[] newList = new int[list.length];
for (int i = 0; i < list.length; i++)
newList[i] = list[list.length - 1 - i];
list = newList;
}
}


▸ Yes

▸ No
Textbook 
Introduction to Java Programming, Comprehensive Version

Introduction to Java Programming, Comprehensive Version


Edition: 10th
Author:
Read 40 times
1 Reply
Replies
Answer verified by a subject expert
cuddahy99cuddahy99
wrote...
Posts: 405
4 years ago
Sign in or Sign up in seconds to unlock everything for free
More solutions for this book are available here
1

Related Topics

Famwam Author
wrote...

4 years ago
You make an excellent tutor!
wrote...

Yesterday
This helped my grade so much Perfect
wrote...

2 hours ago
Thanks
New Topic      
Explore
Post your homework questions and get free online help from our incredible volunteers
  927 People Browsing
Related Images
  
 383
  
 3856
  
 47