Lavi M.

asked • 04/05/20

Find and correct the error(s) in each of the following code fragments :

1. The following code should create an integer array and increment all the array elements by 1:

int[] a = new int[5]; for( int i=0; i <= a.length; i++ ) ++a;



2. The following code should compare two integers to determine if they are not equal:

int x = 9, int y = 3; System.out.print( "x != y " + x != y );


2 Answers By Expert Tutors

By:

Patrick B. answered • 04/05/20

Tutor
4.7 (31)

Math and computer tutor/teacher

Patrick B. answered • 04/05/20

Tutor
4.7 (31)

Math and computer tutor/teacher

Lavi M.

in problem 1 the output is all 1
Report

04/06/20

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.