Results 1 to 3 of 3
  1. #1
    olikhvar is offline Member
    Join Date
    Feb 2008
    Posts
    1
    Rep Power
    0

    Default How to use a function in java

    please let me clear how to use a function in java programming?please reply with some example

  2. #2
    Leprechaun is offline Member
    Join Date
    Dec 2007
    Posts
    30
    Rep Power
    0

    Default

    public class Testing {

    public static int add(int a, int b) {
    return (a + b);
    }

    public static void main(String[] args) {
    int result = add(4, 5);
    System.out.println(result);

    }
    }
    This should help you understand the basics.

  3. #3
    CaptainMorgan's Avatar
    CaptainMorgan is offline Moderator
    Join Date
    Dec 2007
    Location
    NewEngland, US
    Posts
    835
    Rep Power
    10

    Default

    In Java, functions are more typically referred to as methods. See the tutorial on methods for defining them.

    Welcome to the forums! See you around :)
    Vote for the new slogan to our beloved Java Forums! (closes on September 4, 2008)
    Want to voice your opinion on your IDE/Editor of choice? Vote now!
    Got a little Capt'n in you? (drink responsibly)

Similar Threads

  1. Need a little help with a function!
    By Nuluvius in forum New To Java
    Replies: 3
    Last Post: 02-08-2008, 12:33 AM
  2. Use Perl function with java
    By lenny in forum Advanced Java
    Replies: 1
    Last Post: 08-07-2007, 06:25 AM
  3. function name
    By osval in forum Advanced Java
    Replies: 1
    Last Post: 08-06-2007, 08:56 PM
  4. Help with recursive function in java
    By cachi in forum Advanced Java
    Replies: 2
    Last Post: 07-31-2007, 06:51 PM
  5. Php explode function, equivalent java
    By fernando in forum Advanced Java
    Replies: 1
    Last Post: 07-31-2007, 05:44 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •