You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
652 B
Java

Method Overloading
import java.awt.Container;
import javax.swing.*;
public class MethodOverload extends JApplet
{
JTextArea outputArea;
public void init()
{
outputArea = new JTextArea( 2, 20 );
Container c = getContentPane();
c.add( outputArea );
outputArea.setText(
"The square of integer 7 is " + square( 7 ) +
"\nThe square of double 7.5 is " + square( 7.5 ) );
}
public int square( int x )
{
return x * x;
}
public double square( double y )
{
return y * y;
}
}