![]() ** Doubles the first 5 elements of the array */įor (int i = 0 i < values. Getty Images A plane engine - not the aircraft in question A Chinese man who was flying for the first time has been fined for throwing 'good luck' coins into a planes engine. What will the following code print out? Can you write a similar method called tripleFirstFour() that triples the first 4 elements of the array? Make sure you test it in main. Four of them ranked among the worst last year when it comes to on-time arrivals and departures. It is created in the constructor and changed or accessed by the methods. Chinese airlines aren't exactly known for flying on time. Notice that it uses a complex conditional ( &) on line 14 to make sure that the loop doesn’t go beyond the length of the array, because if you had an array that had less than 5 elements, you wouldn’t want the code to try to double the 5th element which doesn’t exist! Notice that in this code, the array is a private instance variable of the class ArrayWorker. The following code doubles the first five elements in an array. You can loop through just some of the elements of an array using a for loop. You don’t have to loop through all of the elements of an array. After the aircraft crew of Anqing Airport discovered it, it immediately stopped it and inspected the aircraft. On October 18, 2017, Xiangpeng Airlines 8L9960 Anqing-Kunming flight during the passenger boarding process, a passenger threw a coin into the aircraft engine. You must start at the length of the array minus one. But in fact, such incidents are not the first time.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |