Respuesta :
Answer:
import java.util.Scanner;
public class U6_L1_Activity_One{
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
int[] arr = new int[4];
arr[1] = scan.nextInt();
arr[2] = scan.nextInt();
arr[3] = scan.nextInt();
System.out.println("Contents: " + arr[1] + " " + arr[2] + " " + arr[3]);
int Sum = (1 + 2 + 3);
System.out.println("Sum: " + Sum);
}
}
Explanation:
Debugging a code involves locating and correcting the errors in the code.
The errors in the code are:
- Invalid array declaration and indexing
- Improper usage of the scanner object
- Incorrect syntax of sum
So, the corrected code segment is as follows:
int [] arr = new int[3];
arr[0] = scan.nextInt();
arr[1] = scan.nextInt();
arr[2] = scan.nextInt();
System.out.println("Contents: " + arr[0] + " " + arr[1] + " " + arr[2]);
System.out.println("Sum: " + (arr[0] + arr[1] + arr[2]));
Read more about debugging at:
https://brainly.com/question/18844825