Код: Выделить всё
// George Beazer
public class TestScores2 {
public TestScores2(int[] arg) {
System.out.println(average(arg));
}
public int average(int[]arg)
{
int temp=0;
for (int i = 0; i < arg.length; i++) {
if(arg[i]100)
{
IllegalArgumentException e = new IllegalArgumentException();
throw e;
}
else
{
temp+=arg[i];
}
}
return temp/arg.length;
}
public static void main(String[] args) {
int []ar={4,78,33,89};
TestScores2 ts=new TestScores2(ar);
}
}
Однако, если я запущу
Код: Выделить всё
public class TestScores2 {
public TestScores2(int[] arg) {
System.out.println(average(arg));
}
public int average(int[]arg)
{
int temp=0;
for (int i = 0; i < arg.length; i++) {
if(arg[i]100)
{
InvalidTestScoreException e = new InvalidTestScore();
throw e;
}
else
{
temp+=arg[i];
}
}
return temp/arg.length;
}
public static void main(String[] args) {
int []ar={4,78,33,89};
TestScores2 ts=new TestScores2(ar);
}
}
Подробнее здесь: https://stackoverflow.com/questions/492 ... se-help-me