##Constructor overloading##
class T
{
T()
{
System.out.println("0-args");
}
T(int i)
{
System.out.println("1-args");
}
T(int i,int j)
{
System.out.println("2-args");
}
public static void main(String[] args)
{
System.out.println("constructor overloading");
T t1=new T();
T t2=new T(10);
T t3=new T(20,30);
}
}
##Method overloading##
class MO {
static int add(int a, int b) {
return a + b;
}
static int add(int a, int b, int c) {
return a + b + c;
}
public static void main(String[] args) {
System.out.println(add(11, 11));
}
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter