Results 1 to 3 of 3
  1. #1
    Bader is offline Member
    Join Date
    Nov 2009
    Posts
    4
    Rep Power
    0

    Default how to write method syntax ?

    hello

    I am trying to return the sum of two double vars here , what i am trying to do is to make a method and call it to be displayed on system message here is what i did

    Java Code:
    //Bader Alrayyes - 8105568
    
    import javax.swing.*;
    public class Functions1 {
    
    	/**
    	 * @param args
    	 */
    	public double DoubleSum(double number1, double number2) {
    		double number3= number1 + number2;
    		return number3;
    	}
    	public static void main(String[] args) {
    		// TODO Auto-generated method stub
    				
    	}
    
    }
    is that corrrect , and how should i display it on system.out.print , i know this is useless but i need to know the basics of writing methods.

  2. #2
    collin389 is offline Senior Member
    Join Date
    Nov 2009
    Posts
    235
    Rep Power
    5

    Default

    in your main method, you would write:
    Java Code:
    Functions1 functionObject = new Functions1();
    System.out.println(functionObject.DoubleSum(3.5, 3.6));

  3. #3
    Bader is offline Member
    Join Date
    Nov 2009
    Posts
    4
    Rep Power
    0

Similar Threads

  1. Trying to write toString method
    By curious in forum New To Java
    Replies: 3
    Last Post: 10-28-2009, 02:43 AM
  2. Syntax correct?
    By dbashby in forum New To Java
    Replies: 5
    Last Post: 09-22-2009, 06:44 AM
  3. Syntax-Check Your XML
    By gilbertsavier in forum XML
    Replies: 0
    Last Post: 07-17-2009, 07:37 AM
  4. Syntax Colouring
    By Doctor Cactus in forum New To Java
    Replies: 2
    Last Post: 02-16-2009, 04:46 PM
  5. Replies: 4
    Last Post: 03-25-2008, 12:16 PM

Tags for this Thread

Posting Permissions

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