Method Overloading in Java


Here is sample code for Method Overloading.

File:meover.java

class meover
{
void san(int a)
{
System.out.println(“The Number is ” +a);
}
void san(String a)
{
System.out.println(“The String value is ” +a);
}
void san(char a)
{
System.out.println(“The Character is ” +a);
}
public static void main(String ar[])
{
meover me=new meover();
me.san(7);
me.san(“Nice”);
me.san(‘S’);
}
}

Output:
The Number is 7
The String value is Nice
The Character is S

Share your queries and comments.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s