packagecom.one;publicclassForStatement{publicstaticvoidmain(String[] args){forStatementTest();}// of mainpublicstaticvoidforStatementTest(){int tempN =10;System.out.println("1 add to "+ tempN +" is: "+addToN(tempN));
tempN =0;System.out.println("1 add to "+ tempN +" is: "+addToN(tempN));int tempStepLength =1;
tempN =10;System.out.println("1 add to "+ tempN +" with step length "+tempStepLength +" is: "+addToNWithStepLength(tempN,tempStepLength));
tempStepLength =2;
tempN =10;System.out.println("1 add to "+ tempN +" with step length "+tempStepLength +" is: "+addToNWithStepLength(tempN,tempStepLength));}// of forStatementTestpublicstaticintaddToN(int paraN){int resultSum =0;for(int i =1; i<= paraN ; i++){
resultSum += i;}// of forreturn resultSum;}// of addToNpublicstaticintaddToNWithStepLength(int paraN,int paraStepLength){int resultSum =0;for(int i =1; i <= paraN ; i += paraStepLength){
resultSum += i;}// of forreturn resultSum;}// of addToNWithStepLength}// of class