public class Largest
{
public static int largest(int[]list)
{
int index,max=list[0];
if(list.length==0)
{
throw new RuntimeException("Emppty List");
}
for(index=0;index<list.length-1;index++)
{
if(list[index]>max)
{
max=list[index];
}
}
return max;
}
}
No comments:
Post a Comment