Dynadot โ€” .com Transfer

[Resolved] Java: Signatures and Method HELP

SpaceshipSpaceship
Watch

zk0

Established Member
Impact
3
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!
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
Unstoppable Domains โ€” AI StorefrontUnstoppable Domains โ€” AI Storefront
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...
 
0
•••
Dynadot โ€” .com TransferDynadot โ€” .com Transfer
Appraise.net
Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
NameMaxi - Your Domain Has Buyers
DomDB
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back