public static void main(String[] args) {
byte[] num1 = new byte[]{5, 6, 8};
int sum1 = sumArray(num1);
sum1 = sumArray(num1);
}
public static int sumArray(byte[] arr) {
int sum = 0;
for(byte i = 0; i < arr.length; i++)
sum += arr [i];
return sum;
}
}
#I dont understand
11 messages · Page 1 of 1 (latest)
⌛ This post has been reserved for your question.
Hey @hoary pollen! Please use
/closeor theClose Postbutton above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
Please format your code to make it more readable.
For java, it should look like this:
````java
public void foo() {
}
````
What about that is confusing?
so you can replace for(byte i = 0; i < arr.length; i++)
with ```java
for(var i: arr){
sum+=i
}
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.