Home > Back-end >  For help! Java total output from 1 to 100, using the method of members, calls to the output
For help! Java total output from 1 to 100, using the method of members, calls to the output

Time:10-09

In Java output from 1 to 100 total, I will, but this member methods how to, ask everybody to help!!!!!! Thank you very much!

CodePudding user response:

CodePudding user response:

reference 1st floor timesong wind xiao xi response:

Can you trouble, write about the process, the small white one

CodePudding user response:

reference 1st floor timesong wind xiao xi response:

Written on the return0 front or back

CodePudding user response:

reference 3 floor biao. T reply:
Quote: refer to 1st floor timesong wind xiao xi response:

Write behind or in front of the return0

This is just a example, you want to return is all 1 to 100
 
Public static void main (String [] args) {
Test t=new Test();
//call member method output
System. The out. Println (t.m emberMthod ());
}

Public int memberMthod () {
Int r=0;
for (int i=1; I & lt;=100; I++) {
R +=I;
}
return r;
}

CodePudding user response:

reference 4 floor timesong wind xiao xi response:
Quote: reference 3 floor biao. T reply:

Quote: refer to 1st floor timesong wind xiao xi response:

Write behind or in front of the return0

This is just a example, you want to return is all 1 to 100
 
Public static void main (String [] args) {
Test t=new Test();
//call member method output
System. The out. Println (t.m emberMthod ());
}

Public int memberMthod () {
Int r=0;
for (int i=1; I & lt;=100; I++) {
R +=I;
}
return r;
}


Ok, thank you, I know,
  • Related