frontPiece
From ggc
http://www.javabat.com/prob?id=Array1.frontPiece
public int[] frontPiece(int[] nums) {
if nums=<1
{ return num[a; }
else if nums=>2 { return num[a,b]; }
return a; }
I don't know how to use an array to display a fraction of an array. Can I even use if statements?
Answer
Individual elements can be obtained from an array by using the array's name followed by the desired location:
nums[0]
for example is the first element in the array.
nums[1]
is the second element in the array. Consult our notes from class about how to create an array. Be sure that you know that an index exists prior to accessing it. For example, nums[1] does not exist if the array only has one element in it.
- This page was last modified on 2 April 2008, at 10:50.
- This page has been accessed 391 times.
- Privacy policy
- About ggc
- Disclaimers
- Powered by MediaWiki!









