Below is a piece of code given me for debugging. I have made a number of changes (noted in code) but still recieve a compile error. Any thoughts will be much appreciated.

My changes-
this was Debug d = new Debug();

this was public method2()

// this class should print to the screen:
// y is 8
// tmp is 20.0 
import java.lang.*;
 
 
public class Debug1 extends java.lang.Object
{
public void main(String[] arguments) 
{
Debug d = new Debug1(); // this was Debug d = new Debug();
int x = 2;
int y = method1(x);
System.out.println("y is " + y);
double tmp =method2();
System.out.println("tmp is " + tmp);
 
} 
public int method1(int xxx) 
{ 
return xxx*4;
}
 
public double method2() // this was public method2()
 
{ 
double x = Math.random();
double y = Math.max(3 * x, 20.0);
return y;
}
 
}

Recommended Answers

All 2 Replies

Debug[B]1[/B] d = new Debug1(); // this was Debug d = new Debug();

Thank you very much. You really need a good eye to catch these things. I am afraid I do not posess such a trait.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.