COSC 111 Lecture Notes - Lecture 16: Method Stub

54 views3 pages
Verified Note

Document Summary

--------------------------------------------- arrays and methods ---------------------------------------------- elem++; x[i]++; public static void main(string[] args) { // todo auto-generated method stub int [] x = {1,2,3,4,5}; //increment all elements in x for(int elem: x) //output: [1, 2, 3, 4, 5] for (int i = 0; i < x. length; i++) //output: [2, 3, 4, 5, 6] import java. util. arrays; public class arraysandmethods { arr[i]++; String temp = ""; for(int item: arr) temp = temp + item + " "; return temp; public static string array2string(int[] arr) { public static void incrarray(int[] arr) { for (int i = 0; i < arr. length; i++) { Copying arrays b[i] = c[i]; int [] b = {1,2,3}; int [] c = {5,6,7}; // copying c to b for (int i = 0; i < c. length; i++) { b=c; b[0] = 9; c[0] = 8; System. out. print("c: "); for (int i = 0; i < c. length; i++) Njh int [] a = {1,2,3}; int [] b = {5,6,7};

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents

Related Questions