• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Overloading

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
import java.util.*;
class Over{
public static void main(String j[])
{
Vector v=new Vector();
Vector v1=new Vector();
System.out.println("value of v"+v);
System.out.println("value of v1"+v1);
Over o = new Over();
o.set(v);
System.out.println("value of v"+v);
System.out.println("value of v1"+v1);
}

public void set(Vector v)
{
v.addElement("100");
v1=v;
System.out.println("value of v"+v);
//// System.out.println("value of v1"+v1);
}
}
Thanks you very much Deeksha ,by mistake i have given the code wrongly.what i want to know is given correctly ,modifycation i made to your code is nothing but given reference of one variable to another.please explain what happens if we do like this

[This message has been edited by sailajauppalapati (edited July 11, 2000).]
[This message has been edited by sailajauppalapati (edited July 11, 2000).]
 
Ranch Hand
Posts: 396
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi sailajauppalapati,
u cud've compiled & run it.anyway the code given by u gave some errors at compile time. so here is the modified code along with output
code with modification
import java.util.*;
class Over{


public static void main(String j[])
{
Vector v=new Vector();
Vector v1=new Vector();
System.out.println("value of v"+v);
System.out.println("value of v1"+v1);
Over o = new Over();
o.set(v);
System.out.println("value of v"+v);
System.out.println("value of v1"+v1);
}

public void set(Vector v)
{
v.addElement("100");
System.out.println("value of v"+v);
//// System.out.println("value of v1"+v1);
}
}
out put is
value of v[]
value of v1[]
value of v[100]
value of v[100]
value of v1[]

regards
deekasha
 
He does not suffer fools gladly. But this tiny ad does:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic