• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

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
reply
    Bookmark Topic Watch Topic
  • New Topic