Results 1 to 2 of 2
Thread: Need help with method
- 02-25-2009, 04:04 PM #1
Member
- Join Date
- Feb 2009
- Posts
- 4
- Rep Power
- 0
Need help with method
I have to make a method that takes an int and adds all of the numbers below it together. For example if you input 5 you would get back 15 because 5+4+3+2+1=15. Im guessing that I have to create a for loop, but thats about as far as ive gotten. This is what i have so far....
public int sumNumbers(int i){
for(int x = i; x >0; x--)
- 02-25-2009, 04:26 PM #2
Senior Member
- Join Date
- Sep 2008
- Posts
- 564
- Rep Power
- 5
Similar Threads
-
method not abstract, does not override actionperformed method.
By Theman in forum New To JavaReplies: 2Last Post: 03-26-2010, 05:12 PM -
static method sparks error on overriding non-static method
By MuslimCoder in forum New To JavaReplies: 1Last Post: 02-10-2009, 10:03 AM -
how to use a variable of one method in another method
By lucasautomacao in forum New To JavaReplies: 4Last Post: 10-29-2008, 02:21 PM -
Calling a method in a different class from within a method problem
By CirKuT in forum New To JavaReplies: 29Last Post: 09-25-2008, 07:55 PM -
cannot call private method from static method
By jon80 in forum New To JavaReplies: 3Last Post: 05-07-2008, 08:37 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks