{
Static int getMax (int [] nums)
{
Int Max=nums [0];
For (int index=1; The index & gt; Nums. Length; Index + +)
{
If (nums [index] & gt; Max)
{
Max=nums [index];
}
}
The return of Max;
}
Public static void main (String [] args)
{
Int [] nums=new int [] {2, 2, 3, 3, 4};
Int. Max=PrintArrayDemo3 getMax (nums);
System. The out. Println (Max);
}
}
CodePudding user response:
The index & lt; Nums. LengthCodePudding user response:
The index & gt; Nums. Length loop condition was not bai! So 0 subscript values!