NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page [resolved] Java: Signatures and Method HELP

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 01-03-2007, 08:16 AM THREAD STARTER               #1 (permalink)
zk0
NamePros Member
 
zk0's Avatar
Join Date: Jun 2005
Posts: 163
zk0 is an unknown quantity at this point
 



Help! Java: Signatures and Method HELP


I need help with this Java code!

I want to count the numbers in the main using the code in the class MyMath. But I dont really understand how? This is what I have done so far but it's not correctly performed and it doesnt count the last line from the main:

Code:
System.out.println(MyMath.add(123, 6.54));
THE CODE:

Code:
package your_username;

public class Program
{
	public static void main(String[] args)
	{
		int intSum = MyMath.add(123, 456);
		System.out.println(intSum);
		
		double doubleSum = MyMath.add(9.87, 6.54);
		System.out.println(doubleSum);

		System.out.println(MyMath.add(123, 6.54));
	}
}

class MyMath
{

	public static int add(int i, int j) {
		System.out.println(">>> metoden med signaturen add(int, int) har anropats <<<");
		return (123+456); // 
	}

	public static double add(double d, double e) {
		System.out.println(">>> metoden med signaturen add(double, double) har anropats <<<");
		return (9.87+6.54); 
	}

}
Thanks for any help in advance!
zk0 is offline  
Old 01-03-2007, 10:12 AM   #2 (permalink)
NamePros Member
Join Date: May 2006
Posts: 160
TwistMyArm is on a distinguished road
 



When you say it doesn't count the last line, what do you mean exactly? Do you mean it's not doing anything, or it's giving you the wrong answer?

I'm assuming you mean the latter and I'm assuming it's because the return values in your class have been hard coded...
TwistMyArm is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Liquid Web Smart Servers  
All times are GMT -7. The time now is 10:46 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger