Home > Back-end >  JavaSE use edit plus is running out why a 2 consult!!!!!!!!!!!
JavaSE use edit plus is running out why a 2 consult!!!!!!!!!!!

Time:10-03

The class PrintArrayDemo3
{
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. Length

CodePudding user response:

The index & gt; Nums. Length loop condition was not bai! So 0 subscript values!
  • Related