5 Replies - 1539 Views - Last Post: 07 January 2010 - 09:44 AM Rate Topic: -----

#1 lakeshira  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 07-January 10

Java-based applications

Posted 07 January 2010 - 08:56 AM

Could someone please explain to me what a method with mutiple parameters does and how they can be used in java based applications?
Is This A Good Question/Topic? 0
  • +

Replies To: Java-based applications

#2 Moshambi  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 8
  • View blog
  • Posts: 280
  • Joined: 20-November 07

Re: Java-based applications

Posted 07 January 2010 - 09:03 AM

A method is the name of a function of a class. If you know about functions and passing parameters then you already know about methods (it's just a different way of saying it).

Do you know how to use functions? How familiar are you with Java? I can go deeper if you need me to.

This post has been edited by Moshambi: 07 January 2010 - 09:04 AM

Was This Post Helpful? 0
  • +
  • -

#3 anonymouscodder  Icon User is offline

  • member icon

Reputation: 126
  • View blog
  • Posts: 710
  • Joined: 01-January 10

Re: Java-based applications

Posted 07 January 2010 - 09:04 AM

'Method with multiple parameters' like this?
void methodWithMultParam(int p1, int p2, int p3) {
	//Something
}

Was This Post Helpful? 0
  • +
  • -

#4 lakeshira  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 07-January 10

Re: Java-based applications

Posted 07 January 2010 - 09:22 AM

View PostMoshambi, on 7 Jan, 2010 - 08:03 AM, said:

A method is the name of a function of a class. If you know about functions and passing parameters then you already know about methods (it's just a different way of saying it).

Do you know how to use functions? How familiar are you with Java? I can go deeper if you need me to.



I'm very unfamilar with Java I have just stared a class and am trying to understand a few things that I couldn't after reading my materials. So please go deeper I would appricate it.

View Postanonymouscodder, on 7 Jan, 2010 - 08:04 AM, said:

'Method with multiple parameters' like this?
void methodWithMultParam(int p1, int p2, int p3) {
	//Something
}


Thanks for the example, do you know any java based applications that use mutiple parameters?
Was This Post Helpful? 0
  • +
  • -

#5 anonymouscodder  Icon User is offline

  • member icon

Reputation: 126
  • View blog
  • Posts: 710
  • Joined: 01-January 10

Re: Java-based applications

Posted 07 January 2010 - 09:28 AM

Your question it's a bit strange since 'method with multiple parameters' is something trivial.
Was This Post Helpful? 0
  • +
  • -

#6 Moshambi  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 8
  • View blog
  • Posts: 280
  • Joined: 20-November 07

Re: Java-based applications

Posted 07 January 2010 - 09:44 AM

I actually just thought of something I never thought of before, let me know if you agree anonymouscodder, in Java all functions would be considered methods since all java applications are within a class, right?

Anyway, lakeshira:


public static int methodName(parameter1, parameter2, parameter3, ....)
{
	  //code to execute
}



You have your declared method. This method has a purpose to carry out some kind of function. Let's say you want to make a method that adds two numbers together and returns the result. You could set it up like this:


public static int add(int n1, int n2)
{
   return (n1 + n2);
}




Now to call this method you would simply:


var sum = add(5,3); // Send method parameters 5 and 3 and store in sum (8)




They are used in lots and lots of programs. They are very useful because you can break up your code into small blocks that different tasks instead of having one giant method with all the code in it. Also it is useful to create methods for doing a task that may need to be done many times throughout running the program, this way all you do is code it once and make a call to it, rather than coding it each time.

Hope that helps a little more.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1